Skip to content

Commit 8330f5a

Browse files
authored
Upgrade to Vitest v3 (openapi-ts#2168)
1 parent ebe56f3 commit 8330f5a

31 files changed

+1636
-1560
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"size-limit": "^11.1.6",
3131
"turbo": "^2.3.4",
3232
"typescript": "^5.7.3",
33-
"vitest": "^2.1.8"
33+
"vitest": "^3.0.6"
3434
},
3535
"size-limit": [
3636
{

packages/openapi-fetch/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"axios": "^1.7.9",
7474
"del-cli": "^5.1.0",
7575
"esbuild": "^0.24.2",
76-
"execa": "^8.0.1",
76+
"execa": "^9.5.2",
7777
"express": "^4.21.2",
7878
"feature-fetch": "^0.0.15",
7979
"node-forge": "^1.3.1",

packages/openapi-fetch/test/http-methods/trace.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ describe("TRACE()", () => {
77
// Node.js does not support TRACE with new Request().
88
test("(not supported in Node.js)", async () => {
99
const client = createObservedClient<paths>();
10-
expect(() => client.TRACE("/resources/{id}", { params: { path: { id: 123 } } })).rejects.toThrow();
10+
await expect(() => client.TRACE("/resources/{id}", { params: { path: { id: 123 } } })).rejects.toThrow();
1111
});
1212
});

packages/openapi-metadata/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
},
6969
"devDependencies": {
7070
"@types/node": "^22.10.5",
71-
"@vitest/coverage-v8": "^2.1.8",
71+
"@vitest/coverage-v8": "^3.0.6",
7272
"reflect-metadata": "^0.2.2",
7373
"typescript": "^5.7.2",
7474
"unbuild": "^3.3.1",

packages/openapi-react-query/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,17 @@
6767
"devDependencies": {
6868
"@tanstack/react-query": "^5.64.2",
6969
"@testing-library/react": "^16.2.0",
70-
"@types/react": "18.3.1",
70+
"@types/react": "^18.3.1",
71+
"@types/react-dom": "^18.3.1",
7172
"@vitejs/plugin-react": "^4.3.4",
7273
"del-cli": "^5.1.0",
7374
"esbuild": "^0.24.2",
74-
"execa": "^8.0.1",
75+
"execa": "^9.5.2",
7576
"msw": "^2.7.0",
7677
"openapi-fetch": "workspace:^",
7778
"openapi-typescript": "workspace:^",
7879
"react": "^18.3.1",
80+
"react-dom": "^18.3.1",
7981
"react-error-boundary": "^4.1.2"
8082
},
8183
"peerDependencies": {

packages/openapi-react-query/test/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ describe("client", () => {
782782
wrapper,
783783
});
784784

785-
expect(result.current.mutateAsync({ body: { message: "Hello", replied_at: 0 } })).rejects.toThrow();
785+
await expect(result.current.mutateAsync({ body: { message: "Hello", replied_at: 0 } })).rejects.toThrow();
786786
});
787787

788788
it("should use provided custom queryClient", async () => {

packages/openapi-typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"degit": "^2.8.4",
7474
"del-cli": "^5.1.0",
7575
"esbuild": "^0.24.2",
76-
"execa": "^8.0.1",
76+
"execa": "^9.5.2",
7777
"strip-ansi": "^7.1.0",
7878
"typescript": "^5.7.3",
7979
"vite-node": "^2.1.8"

packages/openapi-typescript/test/cjs.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ describe("CJS bundle", () => {
88
test(
99
"basic",
1010
async () => {
11+
const contents = astToString(await openapiTS(new URL("../examples/stripe-api.yaml", import.meta.url)));
12+
1113
const output = `/**
1214
* This file was auto-generated by openapi-typescript.
1315
* Do not make direct changes to the file.
1416
*/
1517
16-
${astToString(await openapiTS(new URL("../examples/stripe-api.yaml", import.meta.url)))}`;
17-
expect(output).toMatchFileSnapshot(fileURLToPath(new URL("../examples/stripe-api.ts", import.meta.url)));
18+
${contents}`;
19+
20+
await expect(output).toMatchFileSnapshot(fileURLToPath(new URL("../examples/stripe-api.ts", import.meta.url)));
1821
},
19-
{ timeout: TIMEOUT },
22+
TIMEOUT,
2023
);
2124
});

packages/openapi-typescript/test/cli.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ describe("CLI", () => {
8282
test.skipIf(ci?.skipIf)(
8383
testName,
8484
async () => {
85-
const { stdout } = await execa(cmd, given, { cwd });
85+
const { stdout } = await execa(cmd, given, { cwd, stripFinalNewline: false });
8686
if (want instanceof URL) {
87-
expect(stdout).toMatchFileSnapshot(fileURLToPath(want));
87+
await expect(stdout).toMatchFileSnapshot(fileURLToPath(want));
8888
} else {
8989
expect(stdout).toBe(`${want}\n`);
9090
}
@@ -97,8 +97,8 @@ describe("CLI", () => {
9797
"stdin",
9898
async () => {
9999
const input = fs.readFileSync(new URL("./examples/stripe-api.yaml", root));
100-
const { stdout } = await execa(cmd, { input, cwd });
101-
expect(stdout).toMatchFileSnapshot(fileURLToPath(new URL("./examples/stripe-api.ts", root)));
100+
const { stdout } = await execa(cmd, { input, cwd, stripFinalNewline: false });
101+
await expect(stdout).toMatchFileSnapshot(fileURLToPath(new URL("./examples/stripe-api.ts", root)));
102102
},
103103
TIMEOUT,
104104
);
@@ -119,8 +119,9 @@ describe("CLI", () => {
119119
async () => {
120120
const { stdout } = await execa(cmd, ["--properties-required-by-default=true", "./examples/github-api.yaml"], {
121121
cwd,
122+
stripFinalNewline: false,
122123
});
123-
expect(stdout).toMatchFileSnapshot(fileURLToPath(new URL("./examples/github-api-required.ts", root)));
124+
await expect(stdout).toMatchFileSnapshot(fileURLToPath(new URL("./examples/github-api-required.ts", root)));
124125
},
125126
TIMEOUT,
126127
);
@@ -134,7 +135,7 @@ describe("CLI", () => {
134135
cwd: fileURLToPath(cwd),
135136
});
136137
for (const schema of ["a", "b", "c"]) {
137-
expect(fs.readFileSync(new URL(`./output/${schema}.ts`, cwd), "utf8")).toMatchFileSnapshot(
138+
await expect(fs.readFileSync(new URL(`./output/${schema}.ts`, cwd), "utf8")).toMatchFileSnapshot(
138139
fileURLToPath(new URL("../../../examples/simple-example.ts", cwd)),
139140
);
140141
}
@@ -145,7 +146,7 @@ describe("CLI", () => {
145146
cwd,
146147
});
147148
for (const schema of ["a", "b", "c"]) {
148-
expect(
149+
await expect(
149150
fs.readFileSync(new URL(`./test/fixtures/redocly-flag/output/${schema}.ts`, root), "utf8"),
150151
).toMatchFileSnapshot(fileURLToPath(new URL("./examples/simple-example.ts", root)));
151152
}

packages/openapi-typescript/test/discriminators.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ export type operations = Record<string, never>;`,
635635
async () => {
636636
const result = astToString(await openapiTS(given, options));
637637
if (want instanceof URL) {
638-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
638+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
639639
} else {
640640
expect(result).toBe(`${want}\n`);
641641
}

0 commit comments

Comments
 (0)