forked from tazo90/next-openapi-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
180 lines (175 loc) · 5.79 KB
/
Copy pathvitest.config.ts
File metadata and controls
180 lines (175 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
const rootDir = path.dirname(fileURLToPath(import.meta.url));
const packageSrcDirs = {
"@workspace/openapi-cli": path.join(rootDir, "packages", "openapi-cli", "src"),
"@workspace/openapi-core": path.join(rootDir, "packages", "openapi-core", "src"),
"@workspace/openapi-framework-next": path.join(
rootDir,
"packages",
"openapi-framework-next",
"src",
),
"@workspace/openapi-framework-react-router": path.join(
rootDir,
"packages",
"openapi-framework-react-router",
"src",
),
"@workspace/openapi-framework-tanstack": path.join(
rootDir,
"packages",
"openapi-framework-tanstack",
"src",
),
"@workspace/openapi-init": path.join(rootDir, "packages", "openapi-init", "src"),
"@next-openapi-gen": path.join(rootDir, "packages", "next-openapi-gen", "src"),
"next-openapi-gen": path.join(rootDir, "packages", "next-openapi-gen", "src"),
} as const;
const defaultTestInclude = ["tests/unit/**/*.test.ts", "tests/integration/**/*.test.ts"];
const coverageScopes = {
"next-openapi-gen": {
include: ["packages/next-openapi-gen/src/**/*.ts"],
testInclude: [
"tests/unit/public/**/*.test.ts",
"tests/unit/next/**/*.test.ts",
"tests/unit/react-router/**/*.test.ts",
"tests/unit/vite/**/*.test.ts",
],
thresholds: {
statements: 75,
branches: 75,
functions: 75,
lines: 75,
},
},
"openapi-cli": {
include: ["packages/openapi-cli/src/**/*.ts"],
testInclude: ["tests/unit/cli/**/*.test.ts", "tests/unit/frameworks/index.test.ts"],
thresholds: {
statements: 75,
branches: 75,
functions: 75,
lines: 75,
},
},
"openapi-core": {
include: ["packages/openapi-core/src/**/*.ts"],
testInclude: defaultTestInclude,
thresholds: {
statements: 75,
branches: 75,
functions: 75,
lines: 75,
},
},
"openapi-framework-next": {
include: ["packages/openapi-framework-next/src/**/*.ts"],
testInclude: [
"tests/unit/frameworks/next/**/*.test.ts",
"tests/unit/next/**/*.test.ts",
"tests/unit/routes/app-router-strategy.test.ts",
"tests/unit/routes/pages-router-strategy.test.ts",
],
thresholds: {
statements: 75,
branches: 75,
functions: 75,
lines: 75,
},
},
"openapi-framework-react-router": {
include: ["packages/openapi-framework-react-router/src/**/*.ts"],
testInclude: [
"tests/unit/frameworks/react-router/**/*.test.ts",
"tests/unit/react-router/**/*.test.ts",
],
thresholds: {
statements: 75,
branches: 75,
functions: 75,
lines: 75,
},
},
"openapi-framework-tanstack": {
include: ["packages/openapi-framework-tanstack/src/**/*.ts"],
testInclude: ["tests/unit/frameworks/tanstack/**/*.test.ts", "tests/unit/vite/**/*.test.ts"],
thresholds: {
statements: 75,
branches: 75,
functions: 75,
lines: 75,
},
},
"openapi-init": {
include: ["packages/openapi-init/src/**/*.ts"],
testInclude: ["tests/unit/init/**/*.test.ts"],
thresholds: {
statements: 75,
branches: 75,
functions: 75,
lines: 75,
},
},
} as const;
const coverageScope = process.env.COVERAGE_SCOPE as keyof typeof coverageScopes | undefined;
const selectedCoverageScope = coverageScope ? coverageScopes[coverageScope] : undefined;
if (coverageScope && !selectedCoverageScope) {
throw new Error(`Unknown COVERAGE_SCOPE "${coverageScope}"`);
}
export default defineConfig({
resolve: {
alias: packageSrcDirs,
},
test: {
globals: true,
environment: "node",
include: selectedCoverageScope?.testInclude ?? defaultTestInclude,
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
include: selectedCoverageScope?.include ?? [
"packages/openapi-cli/src/**/*.ts",
"packages/openapi-core/src/**/*.ts",
"packages/openapi-framework-next/src/**/*.ts",
"packages/openapi-framework-react-router/src/**/*.ts",
"packages/openapi-framework-tanstack/src/**/*.ts",
"packages/openapi-init/src/**/*.ts",
"packages/next-openapi-gen/src/**/*.ts",
],
exclude: [
"node_modules/",
"dist/",
"tests/",
"packages/openapi-init/templates/**",
"**/*.d.ts",
"**/*.config.*",
"**/types.ts",
// Pure re-export barrels: coverage is tracked on the concrete modules they load.
"packages/openapi-core/src/index.ts",
// Type-only adapter contracts (no runtime executable statements).
"packages/openapi-core/src/core/adapters.ts",
// TypeScript compiler host wiring is validated indirectly via schema and route tests.
"packages/openapi-core/src/shared/typescript-project.ts",
// Framework route-source glue is covered via framework integration fixtures.
"packages/openapi-core/src/frameworks/shared/generic-route-source.ts",
// Heavy OpenAPI definition merging is covered via generator integration fixtures.
"packages/openapi-core/src/schema/core/schema-definition-processor.ts",
// OpenAPI version coercion is covered via validation fixtures and integration flows.
"packages/openapi-core/src/openapi/version-processor.ts",
// Pure re-export barrels (non-openapi-core — see packages above).
"packages/openapi-framework-next/src/index.ts",
"packages/openapi-framework-tanstack/src/index.ts",
"packages/openapi-framework-react-router/src/index.ts",
"packages/openapi-init/src/index.ts",
],
thresholds: selectedCoverageScope?.thresholds ?? {
statements: 80,
branches: 80,
functions: 80,
lines: 80,
},
},
},
});