Skip to content

Commit f35a075

Browse files
authored
test: update vitest to 2.1.8 (#1496)
* test: update vitest to 2.1.8 * test: compatibility with vitest v2 * update generated vitest version
1 parent a147146 commit f35a075

File tree

7 files changed

+589
-425
lines changed

7 files changed

+589
-425
lines changed

.changeset/angry-pugs-end.md

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

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,11 @@
5454
"ts-jest": "29.1.2",
5555
"turbo": "latest",
5656
"typescript": "~5.2.2",
57-
"vite": "4.5.5",
58-
"vitest": "0.34.6",
57+
"vitest": "2.1.8",
5958
"webpack": "5.91.0",
6059
"yarn": "1.22.22"
6160
},
62-
"overrides": {
63-
"vite": "4.5.5"
64-
},
65-
"resolutions": {
66-
"vite": "4.5.5"
67-
},
61+
"overrides": {},
6862
"workspaces": [
6963
"packages/*",
7064
"smithy-typescript-ssdk-libs/*",

packages/middleware-retry/src/StandardRetryStrategy.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,29 @@ describe("defaultStrategy", () => {
104104
vi.clearAllMocks();
105105
});
106106

107-
it("sets maxAttemptsProvider as class member variable", () => {
108-
[1, 2, 3].forEach((maxAttempts) => {
109-
const retryStrategy = new StandardRetryStrategy(() => Promise.resolve(maxAttempts));
110-
expect(retryStrategy["maxAttemptsProvider"]()).resolves.toBe(maxAttempts);
111-
});
107+
it("sets maxAttemptsProvider as class member variable", async () => {
108+
await Promise.all(
109+
[1, 2, 3].map(async (maxAttempts) => {
110+
const retryStrategy = new StandardRetryStrategy(() => Promise.resolve(maxAttempts));
111+
expect(await retryStrategy["maxAttemptsProvider"]()).toBe(maxAttempts);
112+
})
113+
);
112114
});
113115

114116
it(`sets mode=${RETRY_MODES.STANDARD}`, () => {
115117
const retryStrategy = new StandardRetryStrategy(() => Promise.resolve(maxAttempts));
116118
expect(retryStrategy.mode).toStrictEqual(RETRY_MODES.STANDARD);
117119
});
118120

119-
it("handles non-standard errors", () => {
121+
it("handles non-standard errors", async () => {
120122
const nonStandardErrors = [undefined, "foo", { foo: "bar" }, 123, false, null];
121123
const maxAttempts = 1;
122124
const retryStrategy = new StandardRetryStrategy(() => Promise.resolve(maxAttempts));
123125
for (const error of nonStandardErrors) {
124126
next = vi.fn().mockRejectedValue(error);
125-
expect(retryStrategy.retry(next, { request: { headers: {} } } as any)).rejects.toBeInstanceOf(Error);
127+
expect(await retryStrategy.retry(next, { request: { headers: {} } } as any).catch((_) => _)).toBeInstanceOf(
128+
Error
129+
);
126130
}
127131
});
128132

packages/middleware-retry/src/configurations.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Provider } from "@smithy/types";
12
import { normalizeProvider } from "@smithy/util-middleware";
23
import { AdaptiveRetryStrategy, DEFAULT_MAX_ATTEMPTS, StandardRetryStrategy } from "@smithy/util-retry";
34
import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest";
@@ -17,7 +18,7 @@ describe(resolveRetryConfig.name, () => {
1718

1819
beforeEach(() => {
1920
vi.mocked(normalizeProvider).mockImplementation((input) =>
20-
typeof input === "function" ? input : () => Promise.resolve(input)
21+
typeof input === "function" ? (input as Provider<unknown>) : () => Promise.resolve(input)
2122
);
2223
});
2324

@@ -38,15 +39,15 @@ describe(resolveRetryConfig.name, () => {
3839
});
3940

4041
describe("retryStrategy", () => {
41-
it("passes retryStrategy if present", () => {
42+
it("passes retryStrategy if present", async () => {
4243
const mockRetryStrategy = {
4344
retry: vi.fn(),
4445
};
4546
const { retryStrategy } = resolveRetryConfig({
4647
retryMode,
4748
retryStrategy: mockRetryStrategy,
4849
});
49-
expect(retryStrategy()).resolves.toEqual(mockRetryStrategy);
50+
expect(await retryStrategy()).toEqual(mockRetryStrategy);
5051
});
5152

5253
describe("creates RetryStrategy if retryStrategy not present", () => {
@@ -141,7 +142,7 @@ describe(resolveRetryConfig.name, () => {
141142
it(`should throw if if value of env ${ENV_MAX_ATTEMPTS} is not a number`, () => {
142143
const value = "not a number";
143144
const env = { [ENV_MAX_ATTEMPTS]: value };
144-
expect(() => NODE_MAX_ATTEMPT_CONFIG_OPTIONS.environmentVariableSelector(env)).toThrow("");
145+
expect(() => NODE_MAX_ATTEMPT_CONFIG_OPTIONS.environmentVariableSelector(env)).toThrow();
145146
});
146147
});
147148

@@ -159,7 +160,7 @@ describe(resolveRetryConfig.name, () => {
159160
it(`should throw if shared INI files entry ${CONFIG_MAX_ATTEMPTS} is not a number`, () => {
160161
const value = "not a number";
161162
const profile = { [CONFIG_MAX_ATTEMPTS]: value };
162-
expect(() => NODE_MAX_ATTEMPT_CONFIG_OPTIONS.configFileSelector(profile)).toThrow("");
163+
expect(() => NODE_MAX_ATTEMPT_CONFIG_OPTIONS.configFileSelector(profile)).toThrow();
163164
});
164165
});
165166

packages/util-waiter/src/createWaiter.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("createWaiter", () => {
5353
);
5454
vi.advanceTimersByTime(10 * 1000);
5555
abortController.abort(); // Abort before maxWaitTime(20s);
56-
expect(await statusPromise).toContain(abortedState);
56+
expect(await statusPromise).toMatchObject(abortedState);
5757
});
5858

5959
it("should success when acceptor checker returns seccess", async () => {
@@ -67,7 +67,7 @@ describe("createWaiter", () => {
6767
mockAcceptorChecks
6868
);
6969
vi.advanceTimersByTime(minimalWaiterConfig.minDelay * 1000);
70-
expect(await statusPromise).toContain(successState);
70+
expect(await statusPromise).toMatchObject(successState);
7171
});
7272

7373
it("should fail when acceptor checker returns failure", async () => {
@@ -81,6 +81,6 @@ describe("createWaiter", () => {
8181
mockAcceptorChecks
8282
);
8383
vi.advanceTimersByTime(minimalWaiterConfig.minDelay * 1000);
84-
expect(await statusPromise).toContain(failureState);
84+
expect(await statusPromise).toMatchObject(failureState);
8585
});
8686
});

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptDependency.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public enum TypeScriptDependency implements Dependency {
130130
@Deprecated EXPERIMENTAL_IDENTITY_AND_AUTH("dependencies", "@smithy/experimental-identity-and-auth", false),
131131

132132
// Conditionally added when specs have been generated.
133-
VITEST("devDependencies", "vitest", "^0.33.0", false),
133+
VITEST("devDependencies", "vitest", "2.1.8", false),
134134

135135
// Conditionally added when `generateTypeDoc` is true.
136136
TYPEDOC("devDependencies", "typedoc", "0.23.23", false),

0 commit comments

Comments
 (0)