Skip to content

Commit 8330f5a

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

31 files changed

+1636
-1560
lines changed

package.json

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+4-2
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

+1-1
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

+1-1
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

+6-3
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

+8-7
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

+1-1
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
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ export type operations = Record<string, never>;`,
10261026
async () => {
10271027
const result = astToString(await openapiTS(given, options));
10281028
if (want instanceof URL) {
1029-
expect(want).toMatchFileSnapshot(fileURLToPath(want));
1029+
await expect(want).toMatchFileSnapshot(fileURLToPath(want));
10301030
} else {
10311031
expect(result).toBe(`${want}\n`);
10321032
}

packages/openapi-typescript/test/node-api.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ export type operations = Record<string, never>;`,
982982
async () => {
983983
const result = astToString(await openapiTS(given, options));
984984
if (want instanceof URL) {
985-
expect(`${COMMENT_HEADER}${result}`).toMatchFileSnapshot(fileURLToPath(want));
985+
await expect(`${COMMENT_HEADER}${result}`).toMatchFileSnapshot(fileURLToPath(want));
986986
} else {
987987
expect(result).toBe(`${want}\n`);
988988
}

packages/openapi-typescript/test/transform/components-object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ export type Error = components['schemas']['Error'];
862862
async () => {
863863
const result = astToString(transformComponentsObject(given, options ?? DEFAULT_OPTIONS));
864864
if (want instanceof URL) {
865-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
865+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
866866
} else {
867867
expect(result.trim()).toBe(want.trim());
868868
}

packages/openapi-typescript/test/transform/header-object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("transformHeaderObject", () => {
2929
test.skipIf(ci?.skipIf)(testName, async () => {
3030
const result = astToString(transformHeaderObject(given, options));
3131
if (want instanceof URL) {
32-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
32+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
3333
} else {
3434
expect(result).toBe(`${want}\n`);
3535
}

packages/openapi-typescript/test/transform/operation-object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ responses: {
290290
async () => {
291291
const result = astToString(transformOperationObject(given, options));
292292
if (want instanceof URL) {
293-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
293+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
294294
} else {
295295
expect(result).toBe(`${want}\n`);
296296
}

packages/openapi-typescript/test/transform/path-item-object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ describe("transformPathItemObject", () => {
427427
async () => {
428428
const result = astToString(transformPathItemObject(given, options));
429429
if (want instanceof URL) {
430-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
430+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
431431
} else {
432432
expect(result).toBe(`${want}\n`);
433433
}

packages/openapi-typescript/test/transform/paths-enum.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe("transformPathsObjectToEnum", () => {
114114
async () => {
115115
const result = astToString(makeApiPathsEnum(given));
116116
if (want instanceof URL) {
117-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
117+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
118118
} else {
119119
expect(result).toBe(`${want}\n`);
120120
}

packages/openapi-typescript/test/transform/paths-object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ describe("transformPathsObject", () => {
383383
async () => {
384384
const result = astToString(transformPathsObject(given, options));
385385
if (want instanceof URL) {
386-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
386+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
387387
} else {
388388
expect(result).toBe(`${want}\n`);
389389
}

packages/openapi-typescript/test/transform/request-body-object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ describe("transformRequestBodyObject", () => {
164164
async () => {
165165
const result = astToString(transformRequestBodyObject(given, options));
166166
if (want instanceof URL) {
167-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
167+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
168168
} else {
169169
expect(result).toBe(`${want}\n`);
170170
}

packages/openapi-typescript/test/transform/response-object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe("transformResponseObject", () => {
9090
async () => {
9191
const result = astToString(transformResponseObject(given, options));
9292
if (want instanceof URL) {
93-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
93+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
9494
} else {
9595
expect(result).toBe(`${want}\n`);
9696
}

packages/openapi-typescript/test/transform/schema-object/array.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe("transformSchemaObject > array", () => {
201201
async () => {
202202
const result = astToString(transformSchemaObject(given, options));
203203
if (want instanceof URL) {
204-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
204+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
205205
} else {
206206
expect(result).toBe(`${want}\n`);
207207
}

packages/openapi-typescript/test/transform/schema-object/boolean.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe("transformSchemaObject > boolean", () => {
5050
async () => {
5151
const result = astToString(transformSchemaObject(given, options));
5252
if (want instanceof URL) {
53-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
53+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
5454
} else {
5555
expect(result).toBe(`${want}\n`);
5656
}

packages/openapi-typescript/test/transform/schema-object/composition.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ describe("composition", () => {
620620
async () => {
621621
const result = astToString(transformSchemaObject(given, options));
622622
if (want instanceof URL) {
623-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
623+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
624624
} else {
625625
expect(result).toBe(`${want}\n`);
626626
}

packages/openapi-typescript/test/transform/schema-object/empty.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe("transformSchemaObject > empty/unknown", () => {
4242
async () => {
4343
const result = astToString(transformSchemaObject(given, options));
4444
if (want instanceof URL) {
45-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
45+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
4646
} else {
4747
expect(result).toBe(`${want}\n`);
4848
}

packages/openapi-typescript/test/transform/schema-object/number.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("transformSchemaObject > number", () => {
5858
async () => {
5959
const result = astToString(transformSchemaObject(given, options));
6060
if (want instanceof URL) {
61-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
61+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
6262
} else {
6363
expect(result).toBe(`${want}\n`);
6464
}

packages/openapi-typescript/test/transform/schema-object/object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ describe("transformSchemaObject > object", () => {
419419
async () => {
420420
const result = astToString(transformSchemaObject(given, options));
421421
if (want instanceof URL) {
422-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
422+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
423423
} else {
424424
expect(result).toBe(`${want}\n`);
425425
}

packages/openapi-typescript/test/transform/schema-object/string.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe("transformSchemaObject > string", () => {
127127
async () => {
128128
const result = astToString(transformSchemaObject(given, options));
129129
if (want instanceof URL) {
130-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
130+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
131131
} else {
132132
expect(result).toBe(`${want}\n`);
133133
}

packages/openapi-typescript/test/transform/webhooks-object.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe("transformWebhooksObject", () => {
185185
async () => {
186186
const result = astToString(transformWebhooksObject(given, options));
187187
if (want instanceof URL) {
188-
expect(result).toMatchFileSnapshot(fileURLToPath(want));
188+
await expect(result).toMatchFileSnapshot(fileURLToPath(want));
189189
} else {
190190
expect(result).toBe(`${want}\n`);
191191
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export interface operations {
8989
};
9090
}`);
9191
},
92-
{ timeout: TIMEOUT },
92+
TIMEOUT,
9393
);
9494

9595
test(
@@ -174,6 +174,6 @@ export interface operations {
174174
};
175175
}`);
176176
},
177-
{ timeout: TIMEOUT },
177+
TIMEOUT,
178178
);
179179
});

packages/swr-openapi/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
/* If transpiling with TypeScript: */
2020
"module": "NodeNext",
21+
"moduleResolution": "nodenext",
2122
// "outDir": "dist",
2223
// "rootDir": "src",
2324
"sourceMap": true,

0 commit comments

Comments
 (0)