Skip to content

Commit 44edc40

Browse files
committed
chore(test): update to vitest 3
1 parent b885405 commit 44edc40

File tree

89 files changed

+3720
-4153
lines changed

Some content is hidden

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

89 files changed

+3720
-4153
lines changed

examples/openapi-ts-axios/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
"@hey-api/openapi-ts": "workspace:*",
2525
"@types/react": "19.0.1",
2626
"@types/react-dom": "19.0.1",
27-
"@typescript-eslint/eslint-plugin": "7.18.0",
28-
"@typescript-eslint/parser": "7.15.0",
29-
"@vitejs/plugin-react": "4.3.1",
27+
"@typescript-eslint/eslint-plugin": "8.29.1",
28+
"@typescript-eslint/parser": "8.29.1",
29+
"@vitejs/plugin-react": "4.4.0-beta.1",
3030
"autoprefixer": "10.4.19",
3131
"eslint": "9.17.0",
32-
"eslint-plugin-react-hooks": "4.6.2",
32+
"eslint-plugin-react-hooks": "5.2.0",
3333
"eslint-plugin-react-refresh": "0.4.7",
3434
"postcss": "8.4.41",
3535
"prettier": "3.4.2",
3636
"tailwindcss": "3.4.9",
37-
"typescript": "5.5.3",
38-
"vite": "6.0.13"
37+
"typescript": "5.8.3",
38+
"vite": "6.2.6"
3939
}
4040
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"openapi": "3.1.0",
3+
"info": {
4+
"title": "Petstore API",
5+
"version": "1.0.0",
6+
"description": "A sample API that uses a petstore as an example"
7+
},
8+
"servers": [
9+
{
10+
"url": "http://localhost:3000/v3"
11+
}
12+
],
13+
"paths": {
14+
"/pets/{petId}": {
15+
"get": {
16+
"summary": "Find pet by ID",
17+
"operationId": "showPetById",
18+
"parameters": [
19+
{
20+
"name": "petId",
21+
"in": "path",
22+
"required": true,
23+
"schema": {
24+
"type": "string"
25+
}
26+
}
27+
],
28+
"responses": {
29+
"200": {
30+
"description": "Pet found",
31+
"content": {
32+
"application/json": {
33+
"schema": {
34+
"type": "object",
35+
"properties": {
36+
"id": {
37+
"type": "string"
38+
},
39+
"name": {
40+
"type": "string"
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}
49+
},
50+
"/pets": {
51+
"get": {
52+
"summary": "List all pets",
53+
"operationId": "listPets",
54+
"responses": {
55+
"200": {
56+
"description": "A list of pets",
57+
"content": {
58+
"application/json": {
59+
"schema": {
60+
"type": "array",
61+
"items": {
62+
"type": "object",
63+
"properties": {
64+
"id": {
65+
"type": "string"
66+
},
67+
"name": {
68+
"type": "string"
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}
76+
}
77+
},
78+
"post": {
79+
"summary": "Create a pet",
80+
"operationId": "createPets",
81+
"responses": {
82+
"201": {
83+
"description": "Pet created"
84+
}
85+
}
86+
}
87+
}
88+
}
89+
}

examples/openapi-ts-fastify/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"@hey-api/openapi-ts": "workspace:*",
1818
"eslint": "9.17.0",
1919
"prettier": "3.4.2",
20-
"typescript": "5.5.3",
21-
"vitest": "1.6.0"
20+
"typescript": "5.8.3",
21+
"vite": "6.2.6",
22+
"vitest": "3.1.1"
2223
}
2324
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { buildServer } from './server';
22

3-
const fastify = buildServer();
4-
5-
fastify.listen({ port: 3000 }, function (err) {
6-
if (err) {
7-
fastify.log.error(err);
8-
process.exit(1);
9-
}
3+
buildServer().then((fastify) => {
4+
fastify.listen({ port: 3000 }, function (err) {
5+
if (err) {
6+
fastify.log.error(err);
7+
process.exit(1);
8+
}
9+
});
1010
});

examples/openapi-ts-fastify/src/server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import Fastify from 'fastify';
22
import glue from 'fastify-openapi-glue';
3+
import { readFileSync } from 'fs';
4+
import { join } from 'path';
35

46
import { serviceHandlers } from './handlers';
57

6-
export const buildServer = () => {
8+
export const buildServer = async () => {
79
const fastify = Fastify();
810

9-
const specification = fetch(
10-
'https://gist.githubusercontent.com/seriousme/55bd4c8ba2e598e416bb5543dcd362dc/raw/cf0b86ba37bb54bf1a6bf047c0ecf2a0ce4c62e0/petstore-v3.1.json',
11-
)
12-
.then((reply) => reply.json())
13-
.then((data) => data);
14-
console.log(specification);
11+
const specificationPath = join(__dirname, '..', 'openapi.json');
12+
const specificationJson = JSON.parse(
13+
readFileSync(specificationPath, 'utf-8'),
14+
);
1515

1616
fastify.register(glue, {
1717
prefix: 'v3',
1818
serviceHandlers,
19-
specification,
19+
specification: specificationJson,
2020
});
2121

2222
return fastify;

examples/openapi-ts-fastify/test/pets.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('/pet/findByTags', () => {
88
let server: FastifyInstance;
99

1010
beforeAll(async () => {
11-
server = buildServer();
11+
server = await buildServer();
1212
await server.listen();
1313

1414
// @ts-ignore

examples/openapi-ts-fastify/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"esModuleInterop": true,
1010
"skipLibCheck": true,
1111
"baseUrl": "."
12-
}
12+
},
13+
"references": [{ "path": "./tsconfig.node.json" }]
1314
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"allowSyntheticDefaultImports": true,
8+
"strict": true
9+
},
10+
"include": ["vite.config.ts"]
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
// https://vitejs.dev/config/
4+
export default defineConfig({
5+
plugins: [],
6+
test: {
7+
environment: 'node',
8+
globals: true,
9+
include: ['test/**/*.test.ts'],
10+
watch: false,
11+
},
12+
});

examples/openapi-ts-fetch/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323
"@hey-api/openapi-ts": "workspace:*",
2424
"@types/react": "19.0.1",
2525
"@types/react-dom": "19.0.1",
26-
"@typescript-eslint/eslint-plugin": "7.18.0",
27-
"@typescript-eslint/parser": "7.15.0",
28-
"@vitejs/plugin-react": "4.3.1",
26+
"@typescript-eslint/eslint-plugin": "8.29.1",
27+
"@typescript-eslint/parser": "8.29.1",
28+
"@vitejs/plugin-react": "4.4.0-beta.1",
2929
"autoprefixer": "10.4.19",
3030
"eslint": "9.17.0",
31-
"eslint-plugin-react-hooks": "4.6.2",
31+
"eslint-plugin-react-hooks": "5.2.0",
3232
"eslint-plugin-react-refresh": "0.4.7",
3333
"postcss": "8.4.41",
3434
"prettier": "3.4.2",
3535
"tailwindcss": "3.4.9",
36-
"typescript": "5.5.3",
37-
"vite": "6.0.13"
36+
"typescript": "5.8.3",
37+
"vite": "6.2.6"
3838
}
3939
}

0 commit comments

Comments
 (0)