diff --git a/Makefile b/Makefile index c538995c4861..7dd135969ef1 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,10 @@ test-unit: build-s3-browser-bundle yarn g:vitest run -c vitest.config.clients.unit.ts npx jest -c jest.config.js +# typecheck for test code. +test-types: + npx tsc -p tsconfig.test.json + test-protocols: build-s3-browser-bundle yarn g:vitest run -c vitest.config.protocols.integ.ts @@ -26,6 +30,7 @@ test-integration: build-s3-browser-bundle yarn g:vitest run -c vitest.config.integ.ts npx jest -c jest.config.integ.js make test-protocols; + make test-types; test-e2e: build-s3-browser-bundle yarn g:vitest run -c vitest.config.e2e.ts --retry=4 diff --git a/clients/client-s3/test/e2e/S3.e2e.spec.ts b/clients/client-s3/test/e2e/S3.e2e.spec.ts index e1307c8170b6..91f7024c62fa 100644 --- a/clients/client-s3/test/e2e/S3.e2e.spec.ts +++ b/clients/client-s3/test/e2e/S3.e2e.spec.ts @@ -77,7 +77,7 @@ describe("@aws-sdk/client-s3", () => { const body = createBuffer("1MB"); let bodyChecksum = ""; - const bodyChecksumReader = (next) => async (args) => { + const bodyChecksumReader = (next: any) => async (args: any) => { const checksumValue = args.request.headers["x-amz-checksum-crc32"]; if (checksumValue) { bodyChecksum = checksumValue; diff --git a/clients/client-s3/test/unit/flexibleChecksums.spec.ts b/clients/client-s3/test/unit/flexibleChecksums.spec.ts index 985fe9547b85..710b513c1b30 100644 --- a/clients/client-s3/test/unit/flexibleChecksums.spec.ts +++ b/clients/client-s3/test/unit/flexibleChecksums.spec.ts @@ -84,7 +84,7 @@ describe("Flexible Checksums", () => { expect(headers["transfer-encoding"]).to.equal("chunked"); expect(headers["x-amz-content-sha256"]).to.equal("STREAMING-UNSIGNED-PAYLOAD-TRAILER"); expect(headers["x-amz-trailer"]).to.equal(checksumHeader); - body.on("data", (data) => { + body.on("data", (data: any) => { const stringValue = data.toString(); if (stringValue.startsWith(checksumHeader)) { const receivedChecksum = stringValue.replace("\r\n", "").split(":")[1]; diff --git a/packages/credential-provider-sso/src/resolveSSOCredentials.spec.ts b/packages/credential-provider-sso/src/resolveSSOCredentials.spec.ts index 6f1628b6a10a..ffd505cfe472 100644 --- a/packages/credential-provider-sso/src/resolveSSOCredentials.spec.ts +++ b/packages/credential-provider-sso/src/resolveSSOCredentials.spec.ts @@ -160,7 +160,7 @@ describe(resolveSSOCredentials.name, () => { it("creates SSO client with provided region, if client is not passed", async () => { const mockCustomSsoSend = vi.fn().mockResolvedValue({ roleCredentials: mockCreds }); - vi.mocked(SSOClient).mockReturnValue({ send: mockCustomSsoSend }); + vi.mocked(SSOClient as any).mockReturnValue({ send: mockCustomSsoSend }); await resolveSSOCredentials({ ...mockOptions, ssoClient: undefined }); expect(mockCustomSsoSend).toHaveBeenCalledTimes(1); @@ -176,7 +176,7 @@ describe(resolveSSOCredentials.name, () => { it("creates SSO client with provided region, if client is not passed, and includes accountId", async () => { const mockCustomSsoSend = vi.fn().mockResolvedValue({ roleCredentials: mockCreds }); - vi.mocked(SSOClient).mockReturnValue({ send: mockCustomSsoSend }); + vi.mocked(SSOClient as any).mockReturnValue({ send: mockCustomSsoSend }); const result = await resolveSSOCredentials({ ...mockOptions, ssoClient: undefined }); expect(result).toHaveProperty("accountId", mockOptions.ssoAccountId); diff --git a/packages/credential-providers/src/fromTemporaryCredentials.spec.ts b/packages/credential-providers/src/fromTemporaryCredentials.spec.ts index 18baddd69b97..a3b837f9d66c 100644 --- a/packages/credential-providers/src/fromTemporaryCredentials.spec.ts +++ b/packages/credential-providers/src/fromTemporaryCredentials.spec.ts @@ -62,7 +62,7 @@ describe("fromTemporaryCredentials", () => { secretAccessKey: "SECRET_ACCESS_KEY", sessionToken: "SESSION_TOKEN", }); - expect(vi.mocked(STSClient)).toHaveBeenCalledWith({ + expect(vi.mocked(STSClient as any)).toHaveBeenCalledWith({ credentials: masterCredentials, region, }); @@ -86,7 +86,7 @@ describe("fromTemporaryCredentials", () => { clientPlugins: [plugin], }); await provider(); - expect(vi.mocked(STSClient)).toHaveBeenCalledWith({ + expect(vi.mocked(STSClient as any)).toHaveBeenCalledWith({ credentials: masterCredentials, }); expect(mockUsePlugin).toHaveBeenCalledTimes(1); @@ -101,7 +101,7 @@ describe("fromTemporaryCredentials", () => { }, }); await provider(); - expect(vi.mocked(STSClient)).toHaveBeenCalledWith({}); + expect(vi.mocked(STSClient as any)).toHaveBeenCalledWith({}); }); it("should create a role session name if none provided", async () => { @@ -140,22 +140,22 @@ describe("fromTemporaryCredentials", () => { expect(credentials.accessKeyId).toBe("access_id_from_third"); // Creates STS Client with right master credentials and assume role with // expected role arn. - expect(vi.mocked(STSClient).mock.results.length).toBe(3); - const outmostClient = vi.mocked(STSClient).mock.results[0].value; + expect(vi.mocked(STSClient as any).mock.results.length).toBe(3); + const outmostClient = vi.mocked(STSClient as any).mock.results[0].value; expect(outmostClient.config.credentials).toEqual(expect.objectContaining({ accessKeyId: "access_id_from_second" })); expect((outmostClient.send as any).mock.calls.length).toBe(1); expect((outmostClient.send as any).mock.calls[0][0].input).toEqual( expect.objectContaining({ RoleArn: roleArnOf("third") }) ); - const middleClient = vi.mocked(STSClient).mock.results[1].value; + const middleClient = vi.mocked(STSClient as any).mock.results[1].value; expect(middleClient.config.credentials).toEqual(expect.objectContaining({ accessKeyId: "access_id_from_first" })); expect((middleClient.send as any).mock.calls.length).toBe(1); expect((middleClient.send as any).mock.calls[0][0].input).toEqual( expect.objectContaining({ RoleArn: roleArnOf("second") }) ); - const innermostClient = vi.mocked(STSClient).mock.results[2].value; + const innermostClient = vi.mocked(STSClient as any).mock.results[2].value; expect(innermostClient.config.credentials).toEqual(undefined); expect((innermostClient.send as any).mock.calls.length).toBe(1); expect((innermostClient.send as any).mock.calls[0][0].input).toEqual( @@ -169,7 +169,7 @@ describe("fromTemporaryCredentials", () => { // Should not create extra clients if credentials is still valid await provider(); - expect(vi.mocked(STSClient).mock.results.length).toBe(3); + expect(vi.mocked(STSClient as any).mock.results.length).toBe(3); }); it("should support assuming a role with multi-factor authentication", async () => { diff --git a/packages/eventstream-handler-node/src/EventStreamPayloadHandler.spec.ts b/packages/eventstream-handler-node/src/EventStreamPayloadHandler.spec.ts index e3ffa9a2592a..330de2282f16 100644 --- a/packages/eventstream-handler-node/src/EventStreamPayloadHandler.spec.ts +++ b/packages/eventstream-handler-node/src/EventStreamPayloadHandler.spec.ts @@ -29,7 +29,7 @@ describe(EventStreamPayloadHandler.name, () => { beforeEach(() => { (EventSigningStream as unknown as any).mockImplementation(() => new PassThrough()); - vi.mocked(EventStreamCodec).mockImplementation(() => {}); + vi.mocked(EventStreamCodec).mockImplementation((() => {}) as any); }); afterEach(() => { diff --git a/packages/middleware-bucket-endpoint/src/bucketHostname.spec.ts b/packages/middleware-bucket-endpoint/src/bucketHostname.spec.ts index 1eb2f733b48b..18e5519b1544 100644 --- a/packages/middleware-bucket-endpoint/src/bucketHostname.spec.ts +++ b/packages/middleware-bucket-endpoint/src/bucketHostname.spec.ts @@ -1,5 +1,5 @@ import { parse as parseArn } from "@aws-sdk/util-arn-parser"; -import { describe, expect, expect, test as it } from "vitest"; +import { describe, expect, test as it } from "vitest"; import { bucketHostname } from "./bucketHostname"; diff --git a/packages/middleware-endpoint-discovery/src/getEndpointDiscoveryPlugin.spec.ts b/packages/middleware-endpoint-discovery/src/getEndpointDiscoveryPlugin.spec.ts index 882c6f9391bb..e0e6cdaabeb3 100644 --- a/packages/middleware-endpoint-discovery/src/getEndpointDiscoveryPlugin.spec.ts +++ b/packages/middleware-endpoint-discovery/src/getEndpointDiscoveryPlugin.spec.ts @@ -18,7 +18,7 @@ describe(getEndpointDiscoveryPlugin.name, () => { it(`applyToStack function adds endpoint discovery middleware`, () => { const middlewareReturn = {}; - vi.mocked(endpointDiscoveryMiddleware).mockReturnValueOnce(middlewareReturn); + vi.mocked(endpointDiscoveryMiddleware).mockReturnValueOnce(middlewareReturn as any); // @ts-ignore const plugin = getEndpointDiscoveryPlugin(pluginConfig, middlewareConfig); diff --git a/packages/middleware-flexible-checksums/src/resolveFlexibleChecksumsConfig.spec.ts b/packages/middleware-flexible-checksums/src/resolveFlexibleChecksumsConfig.spec.ts index 404e3df5ec17..06b293d2cbcc 100644 --- a/packages/middleware-flexible-checksums/src/resolveFlexibleChecksumsConfig.spec.ts +++ b/packages/middleware-flexible-checksums/src/resolveFlexibleChecksumsConfig.spec.ts @@ -13,7 +13,7 @@ vi.mock("@smithy/util-middleware"); describe(resolveFlexibleChecksumsConfig.name, () => { beforeEach(() => { - vi.mocked(normalizeProvider).mockImplementation((input) => input); + vi.mocked(normalizeProvider).mockImplementation((input) => input as any); }); afterEach(() => { diff --git a/packages/middleware-flexible-checksums/src/validateChecksumFromResponse.spec.ts b/packages/middleware-flexible-checksums/src/validateChecksumFromResponse.spec.ts index 7829cdd13d2f..836512b99ba2 100644 --- a/packages/middleware-flexible-checksums/src/validateChecksumFromResponse.spec.ts +++ b/packages/middleware-flexible-checksums/src/validateChecksumFromResponse.spec.ts @@ -51,10 +51,12 @@ describe(validateChecksumFromResponse.name, () => { beforeEach(() => { vi.mocked(getChecksumLocationName).mockImplementation((algorithm) => algorithm); - vi.mocked(getChecksumAlgorithmListForResponse).mockImplementation((responseAlgorithms) => responseAlgorithms); + vi.mocked(getChecksumAlgorithmListForResponse).mockImplementation( + (responseAlgorithms) => responseAlgorithms as any + ); vi.mocked(selectChecksumAlgorithmFunction).mockReturnValue(mockChecksumAlgorithmFn); vi.mocked(getChecksum).mockResolvedValue(mockChecksum); - vi.mocked(createChecksumStream).mockReturnValue(mockBodyStream); + vi.mocked(createChecksumStream).mockReturnValue(mockBodyStream as any); }); afterEach(() => { diff --git a/packages/middleware-host-header/src/index.spec.ts b/packages/middleware-host-header/src/index.spec.ts index e708a1006c5a..52e945c28429 100644 --- a/packages/middleware-host-header/src/index.spec.ts +++ b/packages/middleware-host-header/src/index.spec.ts @@ -1,5 +1,5 @@ import { HttpRequest } from "@smithy/protocol-http"; -import { beforeEach, describe, expect, expect, test as it, vi } from "vitest"; +import { beforeEach, describe, expect, test as it, vi } from "vitest"; import { hostHeaderMiddleware } from "./index"; describe("hostHeaderMiddleware", () => { diff --git a/packages/middleware-location-constraint/src/middleware-location-constraint.integ.spec.ts b/packages/middleware-location-constraint/src/middleware-location-constraint.integ.spec.ts index 3f6e84a3c02a..21722cc86a06 100644 --- a/packages/middleware-location-constraint/src/middleware-location-constraint.integ.spec.ts +++ b/packages/middleware-location-constraint/src/middleware-location-constraint.integ.spec.ts @@ -1,5 +1,5 @@ import { S3 } from "@aws-sdk/client-s3"; -import { describe, expect, expect, test as it } from "vitest"; +import { describe, expect, test as it } from "vitest"; import { requireRequestsFrom } from "../../../private/aws-util-test/src"; diff --git a/packages/middleware-sdk-rds/src/middleware-sdk-rds.integ.spec.ts b/packages/middleware-sdk-rds/src/middleware-sdk-rds.integ.spec.ts index 8825c6671171..311fdf109ab9 100644 --- a/packages/middleware-sdk-rds/src/middleware-sdk-rds.integ.spec.ts +++ b/packages/middleware-sdk-rds/src/middleware-sdk-rds.integ.spec.ts @@ -1,5 +1,5 @@ import { RDS } from "@aws-sdk/client-rds"; -import { describe, expect, expect, test as it } from "vitest"; +import { describe, expect, test as it } from "vitest"; import { TestHttpHandler } from "../../../private/aws-util-test/src"; diff --git a/packages/middleware-sdk-route53/src/middleware-sdk-route53.integ.spec.ts b/packages/middleware-sdk-route53/src/middleware-sdk-route53.integ.spec.ts index db1cc54faf30..f40b2d4a2233 100644 --- a/packages/middleware-sdk-route53/src/middleware-sdk-route53.integ.spec.ts +++ b/packages/middleware-sdk-route53/src/middleware-sdk-route53.integ.spec.ts @@ -1,6 +1,6 @@ import { Route53 } from "@aws-sdk/client-route-53"; import { XMLParser } from "fast-xml-parser"; -import { describe, expect, expect, test as it } from "vitest"; +import { describe, expect, test as it } from "vitest"; import { requireRequestsFrom } from "../../../private/aws-util-test/src"; diff --git a/packages/middleware-sdk-s3-control/src/process-arnables-plugin/getProcessArnablesPlugin.spec.ts b/packages/middleware-sdk-s3-control/src/process-arnables-plugin/getProcessArnablesPlugin.spec.ts index eaa978f28731..7d4040dc8692 100644 --- a/packages/middleware-sdk-s3-control/src/process-arnables-plugin/getProcessArnablesPlugin.spec.ts +++ b/packages/middleware-sdk-s3-control/src/process-arnables-plugin/getProcessArnablesPlugin.spec.ts @@ -1,7 +1,7 @@ import { constructStack } from "@smithy/middleware-stack"; import { HttpRequest } from "@smithy/protocol-http"; import { Provider, RegionInfo } from "@smithy/types"; -import { beforeEach, describe, expect, expect, test as it, vi } from "vitest"; +import { beforeEach, describe, expect, test as it, vi } from "vitest"; import { S3ControlResolvedConfig } from "../configurations"; import { getProcessArnablesPlugin } from "./getProcessArnablesPlugin"; diff --git a/packages/middleware-sdk-s3/package.json b/packages/middleware-sdk-s3/package.json index 79aca97c70c5..0be6f0a0d51c 100644 --- a/packages/middleware-sdk-s3/package.json +++ b/packages/middleware-sdk-s3/package.json @@ -10,7 +10,8 @@ "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4", "clean": "rimraf ./dist-* && rimraf *.tsbuildinfo", "test": "yarn g:vitest run", - "test:integration": "yarn g:vitest run -c vitest.config.integ.ts", + "test:types": "tsc -p tsconfig.test.json", + "test:integration": "yarn g:vitest run -c vitest.config.integ.ts && yarn test:types", "test:e2e": "yarn g:vitest run -c vitest.config.e2e.ts --mode development", "extract:docs": "api-extractor run --local", "test:watch": "yarn g:vitest watch", diff --git a/packages/middleware-sdk-s3/src/check-content-length-header.spec.ts b/packages/middleware-sdk-s3/src/check-content-length-header.spec.ts index 27ed5c258ad5..fccebe57f451 100644 --- a/packages/middleware-sdk-s3/src/check-content-length-header.spec.ts +++ b/packages/middleware-sdk-s3/src/check-content-length-header.spec.ts @@ -6,7 +6,7 @@ import { checkContentLengthHeader } from "./check-content-length-header"; describe("checkContentLengthHeaderMiddleware", () => { const mockNextHandler = vi.fn(); - let spy: vi.SpyInstance; + let spy: any; beforeEach(() => { spy = vi.spyOn(console, "warn"); diff --git a/packages/middleware-sdk-s3/src/middleware-sdk-s3.integ.spec.ts b/packages/middleware-sdk-s3/src/middleware-sdk-s3.integ.spec.ts index 6e619da79e69..6ef0cadf972f 100644 --- a/packages/middleware-sdk-s3/src/middleware-sdk-s3.integ.spec.ts +++ b/packages/middleware-sdk-s3/src/middleware-sdk-s3.integ.spec.ts @@ -1,5 +1,5 @@ import { S3 } from "@aws-sdk/client-s3"; -import { describe, expect, expect, test as it, vi } from "vitest"; +import { describe, expect, test as it, vi } from "vitest"; import { requireRequestsFrom } from "../../../private/aws-util-test/src"; diff --git a/packages/middleware-sdk-s3/src/s3-express/middleware-s3-express.e2e.spec.ts b/packages/middleware-sdk-s3/src/s3-express/middleware-s3-express.e2e.spec.ts index 971236036213..e3e1fa20fe0a 100644 --- a/packages/middleware-sdk-s3/src/s3-express/middleware-s3-express.e2e.spec.ts +++ b/packages/middleware-sdk-s3/src/s3-express/middleware-s3-express.e2e.spec.ts @@ -215,7 +215,7 @@ async function createClientAndRecorder() { } const commandName = context.commandName + s3ExpressSuffix; - const input = args.input; + const input = args.input as any; const commandRecorder = (recorder.calls[commandName] = recorder.calls[commandName] ?? {}); commandRecorder[input["Bucket"] ?? "-"] |= 0; commandRecorder[input["Bucket"] ?? "-"]++; diff --git a/packages/middleware-sdk-s3/src/throw-200-exceptions.spec.ts b/packages/middleware-sdk-s3/src/throw-200-exceptions.spec.ts index ab8b0ce09ad9..0dce5f58018d 100644 --- a/packages/middleware-sdk-s3/src/throw-200-exceptions.spec.ts +++ b/packages/middleware-sdk-s3/src/throw-200-exceptions.spec.ts @@ -1,7 +1,7 @@ import { HttpRequest, HttpResponse } from "@smithy/protocol-http"; import { toUtf8 } from "@smithy/util-utf8"; import { Readable } from "stream"; -import { beforeEach, describe, expect, expect, test as it, vi } from "vitest"; +import { beforeEach, describe, expect, test as it, vi } from "vitest"; import { throw200ExceptionsMiddleware } from "./throw-200-exceptions"; diff --git a/packages/middleware-sdk-s3/tsconfig.test.json b/packages/middleware-sdk-s3/tsconfig.test.json new file mode 100644 index 000000000000..22a8661f32d4 --- /dev/null +++ b/packages/middleware-sdk-s3/tsconfig.test.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "rootDir": "src", + "skipLibCheck": true, + "noEmit": true + }, + "extends": "../../tsconfig.cjs.json", + "include": ["src/**/s3-type-transforms.integ.spec.ts"], + "exclude": [] +} diff --git a/packages/middleware-sdk-sqs/src/middleware-sdk-sqs.integ.spec.ts b/packages/middleware-sdk-sqs/src/middleware-sdk-sqs.integ.spec.ts index 914d962d8ba0..833a7ccbdcbd 100644 --- a/packages/middleware-sdk-sqs/src/middleware-sdk-sqs.integ.spec.ts +++ b/packages/middleware-sdk-sqs/src/middleware-sdk-sqs.integ.spec.ts @@ -3,7 +3,7 @@ import { HttpHandler, HttpResponse } from "@smithy/protocol-http"; import type { AwsCredentialIdentity } from "@smithy/types"; import crypto from "crypto"; import { Readable } from "stream"; -import { beforeEach, describe, expect, expect, test as it } from "vitest"; +import { beforeEach, describe, expect, test as it } from "vitest"; import { requireRequestsFrom } from "../../../private/aws-util-test/src"; diff --git a/packages/middleware-signing/src/awsAuthMiddleware.spec.ts b/packages/middleware-signing/src/awsAuthMiddleware.spec.ts index c0d5f1d2884c..84471b94f2e1 100644 --- a/packages/middleware-signing/src/awsAuthMiddleware.spec.ts +++ b/packages/middleware-signing/src/awsAuthMiddleware.spec.ts @@ -1,5 +1,5 @@ import { HttpRequest } from "@smithy/protocol-http"; -import { FinalizeHandler, RequestSigner } from "@smithy/types"; +import { RequestSigner } from "@smithy/types"; import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest"; import { AwsAuthResolvedConfig } from "./awsAuthConfiguration"; @@ -11,11 +11,11 @@ vi.mock("./utils/getUpdatedSystemClockOffset"); vi.mock("./utils/getSkewCorrectedDate"); describe(awsAuthMiddleware.name, () => { - let mockSignFn: vi.Mock; + let mockSignFn: any; let mockSigner: () => Promise; let mockOptions: AwsAuthResolvedConfig; - const mockNext: vi.MockedFunction> = vi.fn(); + const mockNext: any = vi.fn(); const mockSystemClockOffset = 100; const mockUpdatedSystemClockOffset = 500; const mockSigningHandlerArgs = { diff --git a/packages/middleware-token/src/getTokenPlugin.spec.ts b/packages/middleware-token/src/getTokenPlugin.spec.ts index d91199b6c349..b1a2018400dd 100644 --- a/packages/middleware-token/src/getTokenPlugin.spec.ts +++ b/packages/middleware-token/src/getTokenPlugin.spec.ts @@ -18,7 +18,7 @@ describe(getTokenPlugin.name, () => { it("applyToStack adds tokenMiddleware", () => { const middlewareReturn = {}; - vi.mocked(tokenMiddleware).mockReturnValueOnce(middlewareReturn); + vi.mocked(tokenMiddleware).mockReturnValueOnce(middlewareReturn as any); // @ts-ignore const plugin = getTokenPlugin(pluginConfig); diff --git a/packages/middleware-token/src/normalizeTokenProvider.spec.ts b/packages/middleware-token/src/normalizeTokenProvider.spec.ts index 9a4ef2033b78..8ae9412eeeb7 100644 --- a/packages/middleware-token/src/normalizeTokenProvider.spec.ts +++ b/packages/middleware-token/src/normalizeTokenProvider.spec.ts @@ -1,6 +1,6 @@ import { memoize } from "@smithy/property-provider"; import { normalizeProvider } from "@smithy/util-middleware"; -import { afterEach, beforeEach, describe, expect, expect, test as it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest"; import { normalizeTokenProvider } from "./normalizeTokenProvider"; @@ -73,13 +73,13 @@ describe(normalizeTokenProvider.name, () => { }); it("returns true if expiration is not defined", () => { - const memoizeRefreshFn = vi.mocked(memoize).mock.calls[0][2]; + const memoizeRefreshFn = vi.mocked(memoize).mock.calls[0][2]!; const expiration = Date.now(); expect(memoizeRefreshFn({ expiration })).toEqual(true); }); it("returns false if expiration is not defined", () => { - const memoizeRefreshFn = vi.mocked(memoize).mock.calls[0][2]; + const memoizeRefreshFn = vi.mocked(memoize).mock.calls[0][2]!; expect(memoizeRefreshFn({})).toEqual(false); }); }); diff --git a/packages/middleware-user-agent/src/check-features.spec.ts b/packages/middleware-user-agent/src/check-features.spec.ts index d52fa4040504..fb7725564da7 100644 --- a/packages/middleware-user-agent/src/check-features.spec.ts +++ b/packages/middleware-user-agent/src/check-features.spec.ts @@ -15,7 +15,7 @@ describe(checkFeatures.name, () => { identity: { accountId: "123456789012", $source: {}, - }, + } as any, }, }, } as AwsHandlerExecutionContext; diff --git a/packages/middleware-user-agent/src/user-agent-middleware.spec.ts b/packages/middleware-user-agent/src/user-agent-middleware.spec.ts index d305f77e67da..355146df8d51 100644 --- a/packages/middleware-user-agent/src/user-agent-middleware.spec.ts +++ b/packages/middleware-user-agent/src/user-agent-middleware.spec.ts @@ -1,7 +1,7 @@ import { setPartitionInfo, useDefaultPartitionInfo } from "@aws-sdk/util-endpoints"; import { HttpRequest } from "@smithy/protocol-http"; import { UserAgentPair } from "@smithy/types"; -import { afterEach, beforeEach, describe, expect, expect, test as it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest"; import { USER_AGENT, X_AMZ_USER_AGENT } from "./constants"; import { userAgentMiddleware } from "./user-agent-middleware"; diff --git a/packages/middleware-websocket/src/EventStreamPayloadHandler.spec.ts b/packages/middleware-websocket/src/EventStreamPayloadHandler.spec.ts index 70a93a930106..e5b04d3aa80d 100644 --- a/packages/middleware-websocket/src/EventStreamPayloadHandler.spec.ts +++ b/packages/middleware-websocket/src/EventStreamPayloadHandler.spec.ts @@ -1,6 +1,6 @@ import { EventStreamCodec } from "@smithy/eventstream-codec"; import { Decoder, Encoder, FinalizeHandler, FinalizeHandlerArguments, HttpRequest, MessageSigner } from "@smithy/types"; -import { afterEach, beforeEach, describe, expect, expect, test as it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest"; import { ReadableStream, TransformStream } from "web-streams-polyfill"; import { EventStreamPayloadHandler } from "./EventStreamPayloadHandler"; @@ -21,7 +21,7 @@ describe(EventStreamPayloadHandler.name, () => { beforeEach(() => { window.TransformStream = TransformStream; (getEventSigningTransformStream as unknown as any).mockImplementation(() => new TransformStream()); - vi.mocked(EventStreamCodec).mockImplementation(() => {}); + vi.mocked(EventStreamCodec).mockImplementation((() => {}) as any); }); afterEach(() => { diff --git a/packages/middleware-websocket/src/websocket-fetch-handler.spec.ts b/packages/middleware-websocket/src/websocket-fetch-handler.spec.ts index 6194081a03de..b30c93e29dc2 100644 --- a/packages/middleware-websocket/src/websocket-fetch-handler.spec.ts +++ b/packages/middleware-websocket/src/websocket-fetch-handler.spec.ts @@ -2,7 +2,7 @@ import { FetchHttpHandler } from "@smithy/fetch-http-handler"; import { HttpRequest } from "@smithy/protocol-http"; import { WebSocket } from "mock-socket"; import { PassThrough } from "stream"; -import { afterEach, beforeEach, describe, expect, expect, test as it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest"; import WS from "vitest-websocket-mock"; import { WebSocketFetchHandler } from "./websocket-fetch-handler"; @@ -139,7 +139,7 @@ describe(WebSocketFetchHandler.name, () => { expect(err.$metadata).toBeDefined(); expect(err.$metadata.httpStatusCode >= 500).toBe(true); expect( - ((global as any).setTimeout as any).mock.calls.filter((args) => { + ((global as any).setTimeout as any).mock.calls.filter((args: any) => { //find the 'setTimeout' call from the websocket handler return args[0].toString().indexOf("$metadata") >= 0; })[0][1] diff --git a/packages/token-providers/src/fromSso.spec.ts b/packages/token-providers/src/fromSso.spec.ts index 20c906ad2df1..84418060d8ca 100644 --- a/packages/token-providers/src/fromSso.spec.ts +++ b/packages/token-providers/src/fromSso.spec.ts @@ -74,7 +74,7 @@ describe(fromSso.name, () => { describe("throws validation error", () => { it("when profile is not found", async () => { - vi.mocked(parseKnownFiles).mockReturnValue({}); + vi.mocked(parseKnownFiles as any).mockReturnValue({}); const expectedError = new TokenProviderError( `Profile '${mockProfileName}' could not be found in shared credentials file.`, false @@ -84,7 +84,7 @@ describe(fromSso.name, () => { it("when sso_session is not defined for profile", async () => { const { sso_session, ...mockSsoProfileWithoutSsoSession } = mockSsoProfile; - vi.mocked(parseKnownFiles).mockReturnValue({ [mockProfileName]: mockSsoProfileWithoutSsoSession }); + vi.mocked(parseKnownFiles as any).mockReturnValue({ [mockProfileName]: mockSsoProfileWithoutSsoSession }); const expectedError = new TokenProviderError( `Profile '${mockProfileName}' is missing required property 'sso_session'.` ); diff --git a/packages/token-providers/src/getNewSsoOidcToken.spec.ts b/packages/token-providers/src/getNewSsoOidcToken.spec.ts index ea7f87aef2da..b84c51c2bf32 100644 --- a/packages/token-providers/src/getNewSsoOidcToken.spec.ts +++ b/packages/token-providers/src/getNewSsoOidcToken.spec.ts @@ -32,8 +32,8 @@ describe(getNewSsoOidcToken.name, () => { beforeEach(() => { mockSend = vi.fn().mockResolvedValueOnce(mockNewToken); - vi.mocked(getSsoOidcClient).mockReturnValue({ send: mockSend }); - (CreateTokenCommand as unknown as any).mockImplementation((args) => args); + vi.mocked(getSsoOidcClient as any).mockReturnValue({ send: mockSend }); + (CreateTokenCommand as unknown as any).mockImplementation((args: any) => args); }); describe("re-throws", () => { @@ -56,7 +56,7 @@ describe(getNewSsoOidcToken.name, () => { it("if client.send() throws", async () => { const mockSendWithError = vi.fn().mockRejectedValueOnce(mockError); - vi.mocked(getSsoOidcClient).mockReturnValueOnce({ send: mockSendWithError }); + vi.mocked(getSsoOidcClient as any).mockReturnValueOnce({ send: mockSendWithError }); try { await getNewSsoOidcToken(mockSsoToken, mockSsoRegion); fail(`expected ${mockError}`); diff --git a/packages/token-providers/src/getSsoOidcClient.spec.ts b/packages/token-providers/src/getSsoOidcClient.spec.ts index 109f897aa09c..bbaf420c3e6b 100644 --- a/packages/token-providers/src/getSsoOidcClient.spec.ts +++ b/packages/token-providers/src/getSsoOidcClient.spec.ts @@ -9,7 +9,7 @@ describe("getSsoOidcClient", () => { beforeEach(() => { vi.resetModules(); - vi.mocked(SSOOIDCClient).mockImplementation((({ region }) => getMockClient(region)) as any); + vi.mocked(SSOOIDCClient as any).mockImplementation((({ region }: any) => getMockClient(region)) as any); }); afterEach(() => { diff --git a/packages/token-providers/src/nodeProvider.spec.ts b/packages/token-providers/src/nodeProvider.spec.ts index d993d197ffec..dc0ae787c30b 100644 --- a/packages/token-providers/src/nodeProvider.spec.ts +++ b/packages/token-providers/src/nodeProvider.spec.ts @@ -29,7 +29,7 @@ describe(nodeProvider.name, () => { [chain, mockChainFn], [memoize, mockMemoizeFn], ].forEach(([fromFn, mockFn]) => { - vi.mocked(fromFn).mockReturnValue(mockFn); + vi.mocked(fromFn).mockReturnValue(mockFn as any); }); }); @@ -99,13 +99,13 @@ describe(nodeProvider.name, () => { }); it("returns true if expiration is not defined", () => { - const memoizeRefreshFn = vi.mocked(memoize).mock.calls[0][2]; + const memoizeRefreshFn = vi.mocked(memoize).mock.calls[0][2]!; const expiration = Date.now(); expect(memoizeRefreshFn({ expiration })).toEqual(true); }); it("returns false if expiration is not defined", () => { - const memoizeRefreshFn = vi.mocked(memoize).mock.calls[0][2]; + const memoizeRefreshFn = vi.mocked(memoize).mock.calls[0][2]!; expect(memoizeRefreshFn({})).toEqual(false); }); }); diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 000000000000..9a9c14442761 --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "noEmit": true + }, + "extends": "./tsconfig.cjs.json", + "include": ["packages/**/*.spec.ts", "lib/**/*.spec.ts", "clients/**/*.spec.ts", "private/**/*.spec.ts"], + "exclude": [ + "node_modules/", + "vitest.*.ts", + "clients/client-s3/test/e2e/S3.browser.e2e.spec.ts", + "private/aws-restjson-server/**/*.spec.ts", + "private/aws-restjson-validation-server/**/*.spec.ts" + ] +}