Skip to content

Commit

Permalink
test: fix type checks in e2e tests (#6075)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored May 8, 2024
1 parent 74e4c14 commit 3179af2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions packages/ec2-metadata-service/src/MetadataService.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { fromInstanceMetadata } from "@aws-sdk/credential-providers";
import { MetadataService } from "./MetadataService";

describe("MetadataService E2E Tests", () => {
let metadataService;
let metadataService: any;
const provider = fromInstanceMetadata({ timeout: 1000, maxRetries: 0 });
let metadataServiceAvailable;
let metadataServiceAvailable: any;

beforeAll(async () => {
try {
Expand Down Expand Up @@ -35,7 +35,7 @@ describe("MetadataService E2E Tests", () => {
if (!metadataServiceAvailable) {
return;
}
const metadata = await metadataService.request("/latest/meta-data/", {});
const metadata = (await metadataService.request("/latest/meta-data/", {})) as string;
expect(metadata).toBeDefined();
expect(typeof metadata).toBe("string");
const lines = metadata.split("\n").map((line) => line.trim());
Expand All @@ -49,7 +49,7 @@ describe("MetadataService E2E Tests", () => {
return;
}
metadataService.disableFetchToken = true; // make request without token
const metadata = await metadataService.request("/latest/meta-data/", {});
const metadata = (await metadataService.request("/latest/meta-data/", {})) as string;
expect(metadata).toBeDefined();
expect(typeof metadata).toBe("string");
expect(metadata.length).toBeGreaterThan(0);
Expand All @@ -67,7 +67,7 @@ describe("MetadataService E2E Tests", () => {
throw { name: "TimeoutError" }; // Simulating TimeoutError
});
// Attempt to fetch metadata, expecting IMDSv1 fallback (request without token)
const metadata = await metadataService.request("/latest/meta-data/", {});
const metadata = (await metadataService.request("/latest/meta-data/", {})) as string;
expect(metadata).toBeDefined();
expect(typeof metadata).toBe("string");
const lines = metadata.split("\n").map((line) => line.trim());
Expand All @@ -85,7 +85,7 @@ describe("MetadataService E2E Tests", () => {
jest.spyOn(metadataService, "fetchMetadataToken").mockImplementationOnce(async () => {
throw { statusCode: errorCode };
});
const metadata = await metadataService.request("/latest/meta-data/", {});
const metadata = (await metadataService.request("/latest/meta-data/", {})) as string;
expect(metadata).toBeDefined();
expect(typeof metadata).toBe("string");
const lines = metadata.split("\n").map((line) => line.trim());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ async function createClientAndRecorder() {
const commandName = context.commandName + s3ExpressSuffix;
const input = args.input;
const commandRecorder = (recorder.calls[commandName] = recorder.calls[commandName] ?? {});
// @ts-expect-error Element implicitly has an 'any' type
commandRecorder[input["Bucket"] ?? "-"] |= 0;
// @ts-expect-error Element implicitly has an 'any' type
commandRecorder[input["Bucket"] ?? "-"]++;

return continuation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe(createPresignedPost.name, () => {
expect(precheck).toBeInstanceOf(NoSuchKey);

const submit: { statusCode: number } = await new Promise((resolve, reject) => {
form.submit(url, (err, res) => {
form.submit(url, (err: any, res: any) => {
if (err) reject(err);
resolve(res);
});
Expand Down

0 comments on commit 3179af2

Please sign in to comment.