Skip to content

Commit e5bb1e2

Browse files
authored
test: run tests with vitest, fix test type errors (#1602)
* chore: fix command retry script * chore: test typefixes and update to integ test model
1 parent 23812a9 commit e5bb1e2

File tree

52 files changed

+214
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+214
-119
lines changed

.changeset/rare-dancers-sparkle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ generate-protocol-tests:
1818
test-protocols:
1919
(cd ./private/smithy-rpcv2-cbor && npx vitest run --globals)
2020

21+
test-unit:
22+
yarn g:vitest run -c vitest.config.ts
23+
24+
test-browser:
25+
yarn g:vitest run -c vitest.config.browser.ts
26+
27+
# typecheck for test code.
28+
test-types:
29+
npx tsc -p tsconfig.test.json
30+
31+
test-integration:
32+
make test-browser
33+
yarn g:vitest run -c vitest.config.integ.ts
34+
make test-types
35+
2136
turbo-clean:
2237
@read -p "Are you sure you want to delete your local cache? [y/N]: " ans && [ $${ans:-N} = y ]
2338
@echo "\nDeleted cache folders: \n--------"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"scripts": {
88
"clean": "turbo run clean --force --parallel",
99
"build": "turbo run build",
10-
"test": "turbo run test",
11-
"test:integration": "yarn build-test-packages && turbo run test:integration",
10+
"test": "make test-unit",
11+
"test:integration": "yarn build-test-packages && make test-integration",
1212
"test:protocols": "make generate-protocol-tests test-protocols",
1313
"lint": "turbo run lint",
1414
"lint-fix": "turbo run lint -- --fix",

packages/config-resolver/src/regionConfig/isFipsRegion.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ describe(isFipsRegion.name, () => {
1212
});
1313

1414
it.each([undefined, null])("returns false for %s", (input) => {
15-
expect(isFipsRegion(input)).toEqual(false);
15+
expect(isFipsRegion(input as any)).toEqual(false);
1616
});
1717
});

packages/config-resolver/src/regionConfig/resolveRegionConfig.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ describe("RegionConfig", () => {
5454
});
5555

5656
describe("useFipsEndpoint", () => {
57-
let mockRegionProvider;
58-
let mockUseFipsEndpoint;
57+
let mockRegionProvider: () => Promise<string>;
58+
let mockUseFipsEndpoint: () => Promise<boolean>;
5959

6060
beforeEach(() => {
6161
mockRegionProvider = vi.fn().mockResolvedValueOnce(Promise.resolve(mockRegion));

packages/config-resolver/src/regionInfo/getRegionInfo.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ describe(getRegionInfo.name, () => {
5656
const getMockResolvedRegion = (regionCase: RegionCase): string =>
5757
regionCase !== RegionCase.ENDPOINT ? mockRegion : mockEndpointRegion;
5858

59-
const getMockResolvedPartitionOptions = (partitionHash) => ({ partitionHash });
59+
const getMockResolvedPartitionOptions = (partitionHash: PartitionHash) => ({ partitionHash });
6060

61-
const getMockRegionInfoOptions = (regionHash, getResolvedPartitionOptions) => ({
61+
const getMockRegionInfoOptions = (regionHash: RegionHash, getResolvedPartitionOptions: any) => ({
6262
...getResolvedPartitionOptions,
6363
signingService: mockSigningService,
6464
regionHash,

packages/config-resolver/src/regionInfo/getResolvedPartition.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ describe(getResolvedPartition.name, () => {
3232
});
3333

3434
it("returns aws if partitionHash is empty", () => {
35-
expect(getResolvedPartition(mockRegion, { partitionHash: undefined })).toBe("aws");
35+
expect(getResolvedPartition(mockRegion, { partitionHash: undefined as any })).toBe("aws");
3636
});
3737
});

packages/core/src/submodules/cbor/cbor.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fs from "fs";
2+
// @ts-ignore
23
import JSONbig from "json-bigint";
34
import * as path from "path";
45
import { describe, expect, test as it } from "vitest";
@@ -290,7 +291,7 @@ describe("cbor", () => {
290291
return scalar * sum * exponentScalar;
291292
}
292293

293-
function translateTestData(data: any) {
294+
function translateTestData(data: any): any {
294295
const [type, value] = Object.entries(data)[0] as [string, any];
295296
switch (type) {
296297
case "null":

packages/core/src/submodules/schema/middleware/schemaDeserializationMiddleware.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe(schemaDeserializationMiddleware.name, () => {
8585
expect(mockNext).toHaveBeenCalledWith(mockArgs);
8686
expect(mockDeserializer).toHaveBeenCalledTimes(1);
8787
expect(mockDeserializer).toHaveBeenCalledWith(
88-
undefined as SchemaRef,
88+
undefined as any as SchemaRef,
8989
{
9090
...mockOptions,
9191
__smithy_context: {},

packages/core/src/submodules/schema/middleware/schemaSerializationMiddleware.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe(schemaSerializationMiddleware.name, () => {
5959
await expect(schemaSerializationMiddleware(mockOptions)(mockNext, {})(mockArgs)).resolves.toStrictEqual(mockReturn);
6060

6161
expect(mockSerializer).toHaveBeenCalledTimes(1);
62-
expect(mockSerializer).toHaveBeenCalledWith(undefined as SchemaRef, mockArgs.input, {
62+
expect(mockSerializer).toHaveBeenCalledWith(undefined as unknown as SchemaRef, mockArgs.input, {
6363
...mockOptions,
6464
__smithy_context: {},
6565
});

0 commit comments

Comments
 (0)