@aamini/config 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{playwright.shared.config.d.mts → playwright.d.mts} +2 -3
- package/dist/{playwright.shared.config.mjs → playwright.mjs} +2 -3
- package/dist/playwright.mjs.map +1 -0
- package/dist/setup/styles.mjs +0 -1
- package/dist/test/browser.d.mts +7 -2
- package/dist/test/browser.mjs +5 -3
- package/dist/test/browser.mjs.map +1 -1
- package/dist/test/db.d.mts +34 -7
- package/dist/test/db.mjs +29 -15
- package/dist/test/db.mjs.map +1 -1
- package/dist/test/server.d.mts +7 -3
- package/dist/test/server.mjs +3 -4
- package/dist/test/server.mjs.map +1 -1
- package/dist/vite.d.mts +81 -0
- package/dist/vite.mjs +211 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +43 -47
- package/tsconfig/tsconfig.tanstack.json +1 -1
- package/dist/internal-Dshd0hdM.mjs +0 -22
- package/dist/internal-Dshd0hdM.mjs.map +0 -1
- package/dist/playwright.shared.config.mjs.map +0 -1
- package/dist/test/database.d.mts +0 -22
- package/dist/test/database.mjs +0 -18
- package/dist/test/database.mjs.map +0 -1
- package/dist/test/playwright.d.mts +0 -7
- package/dist/test/playwright.mjs +0 -15
- package/dist/test/playwright.mjs.map +0 -1
- package/dist/test/postgres.d.mts +0 -14
- package/dist/test/postgres.mjs +0 -25
- package/dist/test/postgres.mjs.map +0 -1
- package/dist/test/visual-page.d.mts +0 -36
- package/dist/test/visual-page.mjs +0 -30
- package/dist/test/visual-page.mjs.map +0 -1
- package/dist/vite.shared.d.mts +0 -379
- package/dist/vite.shared.mjs +0 -302
- package/dist/vite.shared.mjs.map +0 -1
- package/dist/vitest.shared.d.mts +0 -12
- package/dist/vitest.shared.mjs +0 -122
- package/dist/vitest.shared.mjs.map +0 -1
- package/msw.ts +0 -5
- package/playwright.shared.config.ts +0 -71
- package/setup/styles.ts +0 -4
- package/test/browser.ts +0 -44
- package/test/database.ts +0 -38
- package/test/db.ts +0 -86
- package/test/internal.ts +0 -45
- package/test/playwright.ts +0 -17
- package/test/postgres.ts +0 -43
- package/test/server.ts +0 -43
- package/test/visual-page.ts +0 -57
- package/tsconfig/tsconfig.astro.json +0 -34
- package/tsconfig/tsconfig.react.json +0 -16
- package/virtual-modules.d.ts +0 -6
- package/vite.config.ts +0 -53
- package/vite.shared.ts +0 -411
- package/vitest.shared.ts +0 -183
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// TODO: remove
|
|
3
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
4
|
-
"extends": "./tsconfig.strict.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
// Enable top-level await, and other modern ESM features.
|
|
7
|
-
"target": "ESNext",
|
|
8
|
-
"module": "ESNext",
|
|
9
|
-
// Enable module resolution without file extensions on relative paths, for things like npm package imports.
|
|
10
|
-
"moduleResolution": "Bundler",
|
|
11
|
-
// Allow importing TypeScript files using their native extension (.ts(x)).
|
|
12
|
-
"allowImportingTsExtensions": true,
|
|
13
|
-
// Enable JSON imports.
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
// Enforce the usage of type-only imports when needed, which helps avoiding bundling issues.
|
|
16
|
-
"verbatimModuleSyntax": true,
|
|
17
|
-
// Ensure that each file can be transpiled without relying on other imports.
|
|
18
|
-
// This is redundant with the previous option, however it ensures that it's on even if someone disable `verbatimModuleSyntax`
|
|
19
|
-
"isolatedModules": true,
|
|
20
|
-
// Astro directly run TypeScript code, no transpilation needed.
|
|
21
|
-
"noEmit": true,
|
|
22
|
-
// Report an error when importing a file using a casing different from another import of the same file.
|
|
23
|
-
"forceConsistentCasingInFileNames": true,
|
|
24
|
-
// Properly support importing CJS modules in ESM
|
|
25
|
-
"esModuleInterop": true,
|
|
26
|
-
// Skip typechecking libraries and .d.ts files
|
|
27
|
-
"skipLibCheck": true,
|
|
28
|
-
// Allow JavaScript files to be imported
|
|
29
|
-
"allowJs": true,
|
|
30
|
-
// Allow JSX files (or files that are internally considered JSX, like Astro files) to be imported inside `.js` and `.ts` files.
|
|
31
|
-
"jsx": "react-jsx",
|
|
32
|
-
"jsxImportSource": "react"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "./tsconfig.strict.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"target": "ES2022",
|
|
6
|
-
"jsx": "react-jsx",
|
|
7
|
-
"module": "ESNext",
|
|
8
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
9
|
-
|
|
10
|
-
/* Bundler mode */
|
|
11
|
-
"moduleResolution": "bundler",
|
|
12
|
-
"allowImportingTsExtensions": true,
|
|
13
|
-
"verbatimModuleSyntax": false,
|
|
14
|
-
"noEmit": true
|
|
15
|
-
}
|
|
16
|
-
}
|
package/virtual-modules.d.ts
DELETED
package/vite.config.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite-plus'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
pack: {
|
|
5
|
-
entry: [
|
|
6
|
-
'vite.shared.ts',
|
|
7
|
-
'vitest.shared.ts',
|
|
8
|
-
'playwright.shared.config.ts',
|
|
9
|
-
'msw.ts',
|
|
10
|
-
'test/browser.ts',
|
|
11
|
-
'test/database.ts',
|
|
12
|
-
'test/db.ts',
|
|
13
|
-
'test/playwright.ts',
|
|
14
|
-
'test/postgres.ts',
|
|
15
|
-
'test/server.ts',
|
|
16
|
-
'test/visual-page.ts',
|
|
17
|
-
'setup/styles.ts',
|
|
18
|
-
],
|
|
19
|
-
dts: true,
|
|
20
|
-
format: ['esm'],
|
|
21
|
-
sourcemap: true,
|
|
22
|
-
deps: {
|
|
23
|
-
skipNodeModulesBundle: true,
|
|
24
|
-
neverBundle: [
|
|
25
|
-
'@playwright/test',
|
|
26
|
-
'@rolldown/plugin-babel',
|
|
27
|
-
'@tailwindcss/vite',
|
|
28
|
-
'@tanstack/devtools-vite',
|
|
29
|
-
'@tanstack/react-start',
|
|
30
|
-
'@test/handlers',
|
|
31
|
-
'@test/styles',
|
|
32
|
-
'@testing-library/jest-dom',
|
|
33
|
-
'@testcontainers/postgresql',
|
|
34
|
-
'@vitejs/plugin-react',
|
|
35
|
-
'@vitest/browser-playwright',
|
|
36
|
-
'@voidzero-dev/vite-plus-core',
|
|
37
|
-
'@voidzero-dev/vite-plus-test',
|
|
38
|
-
'drizzle-orm',
|
|
39
|
-
'drizzle-seed',
|
|
40
|
-
'msw',
|
|
41
|
-
'nitro',
|
|
42
|
-
'pg',
|
|
43
|
-
'react',
|
|
44
|
-
'testcontainers',
|
|
45
|
-
'vite',
|
|
46
|
-
'vite-plus',
|
|
47
|
-
'vite-plugin-svgr',
|
|
48
|
-
'vitest',
|
|
49
|
-
'vitest-browser-react',
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
})
|
package/vite.shared.ts
DELETED
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
import { nitro } from 'nitro/vite'
|
|
2
|
-
import { devtools } from '@tanstack/devtools-vite'
|
|
3
|
-
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
|
|
4
|
-
import viteReact, { reactCompilerPreset } from '@vitejs/plugin-react'
|
|
5
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
6
|
-
import babel from '@rolldown/plugin-babel'
|
|
7
|
-
import svgr from 'vite-plugin-svgr'
|
|
8
|
-
import { existsSync } from 'node:fs'
|
|
9
|
-
import { dirname, resolve } from 'node:path'
|
|
10
|
-
import { fileURLToPath } from 'node:url'
|
|
11
|
-
import type { Plugin } from 'vite'
|
|
12
|
-
import {
|
|
13
|
-
defineConfig as defineVitestConfig,
|
|
14
|
-
mergeConfig,
|
|
15
|
-
type TestProjectConfiguration,
|
|
16
|
-
type TestProjectInlineConfiguration,
|
|
17
|
-
} from 'vitest/config'
|
|
18
|
-
import { defineConfig } from 'vite'
|
|
19
|
-
import { playwright } from 'vite-plus/test/browser-playwright'
|
|
20
|
-
|
|
21
|
-
const HANDLER_LOCATIONS = [
|
|
22
|
-
'__mocks__/handlers.ts',
|
|
23
|
-
'__mocks__/handlers.js',
|
|
24
|
-
'src/mocks/handlers.ts',
|
|
25
|
-
'src/mocks/handlers.js',
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
const STYLES_LOCATIONS = ['src/styles.css', 'src/index.css', 'src/app.css']
|
|
29
|
-
|
|
30
|
-
function mswHandlersPlugin(root: string): Plugin {
|
|
31
|
-
const virtualModuleId = '@test/handlers'
|
|
32
|
-
const resolvedVirtualModuleId = '\0' + virtualModuleId
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
name: 'msw-handlers-resolver',
|
|
36
|
-
resolveId(id) {
|
|
37
|
-
if (id === virtualModuleId) {
|
|
38
|
-
return resolvedVirtualModuleId
|
|
39
|
-
}
|
|
40
|
-
return undefined
|
|
41
|
-
},
|
|
42
|
-
load(id) {
|
|
43
|
-
if (id === resolvedVirtualModuleId) {
|
|
44
|
-
for (const location of HANDLER_LOCATIONS) {
|
|
45
|
-
const fullPath = resolve(root, location)
|
|
46
|
-
if (existsSync(fullPath)) {
|
|
47
|
-
return `export { default } from '${fullPath}'`
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
throw new Error(
|
|
51
|
-
`No MSW handlers found. Expected one of:\n${HANDLER_LOCATIONS.map((l) => ` - ${resolve(root, l)}`).join('\n')}`,
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
return undefined
|
|
55
|
-
},
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function stylesPlugin(root: string): Plugin {
|
|
60
|
-
const virtualModuleId = '@test/styles'
|
|
61
|
-
const resolvedVirtualModuleId = '\0' + virtualModuleId
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
name: 'styles-resolver',
|
|
65
|
-
resolveId(id) {
|
|
66
|
-
if (id === virtualModuleId) {
|
|
67
|
-
return resolvedVirtualModuleId
|
|
68
|
-
}
|
|
69
|
-
return undefined
|
|
70
|
-
},
|
|
71
|
-
load(id) {
|
|
72
|
-
if (id === resolvedVirtualModuleId) {
|
|
73
|
-
for (const location of STYLES_LOCATIONS) {
|
|
74
|
-
const fullPath = resolve(root, location)
|
|
75
|
-
if (existsSync(fullPath)) {
|
|
76
|
-
return `import '${fullPath}'`
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
throw new Error(
|
|
80
|
-
`No styles file found. Expected one of:\n${STYLES_LOCATIONS.map((l) => ` - ${resolve(root, l)}`).join('\n')}`,
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
return undefined
|
|
84
|
-
},
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const stylesSetup = '@aamini/config/setup/styles'
|
|
89
|
-
|
|
90
|
-
function mergeProjectConfig(
|
|
91
|
-
base: TestProjectConfiguration,
|
|
92
|
-
overrides: TestProjectConfiguration = {},
|
|
93
|
-
): TestProjectConfiguration {
|
|
94
|
-
return mergeConfig(
|
|
95
|
-
base as Record<string, any>,
|
|
96
|
-
overrides as Record<string, any>,
|
|
97
|
-
) as TestProjectConfiguration
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
interface ProjectOverrides {
|
|
101
|
-
server?: TestProjectConfiguration
|
|
102
|
-
browser?: TestProjectConfiguration
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function createBaseConfig(
|
|
106
|
-
root: string,
|
|
107
|
-
overrides: TestProjectInlineConfiguration = {},
|
|
108
|
-
projectOverrides: ProjectOverrides = {},
|
|
109
|
-
) {
|
|
110
|
-
const localSetup = resolve(root, 'vitest.setup.ts')
|
|
111
|
-
const hasLocalSetup = existsSync(localSetup)
|
|
112
|
-
|
|
113
|
-
return mergeConfig(
|
|
114
|
-
defineVitestConfig({
|
|
115
|
-
root,
|
|
116
|
-
resolve: {
|
|
117
|
-
tsconfigPaths: true,
|
|
118
|
-
dedupe: ['react', 'react-dom'],
|
|
119
|
-
alias: [
|
|
120
|
-
{ find: '@/mocks', replacement: resolve(root, '__mocks__') },
|
|
121
|
-
{ find: '@', replacement: resolve(root, 'src') },
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
plugins: [
|
|
125
|
-
tailwindcss(),
|
|
126
|
-
svgr({
|
|
127
|
-
include: '**/*.svg',
|
|
128
|
-
svgrOptions: { exportType: 'default' },
|
|
129
|
-
}),
|
|
130
|
-
],
|
|
131
|
-
test: {
|
|
132
|
-
passWithNoTests: true,
|
|
133
|
-
exclude: [
|
|
134
|
-
'**/node_modules/**',
|
|
135
|
-
'**/dist/**',
|
|
136
|
-
'**/.output/**',
|
|
137
|
-
'**/.vercel/**',
|
|
138
|
-
'**/cypress/**',
|
|
139
|
-
'**/.{idea,git,cache,output,temp}/**',
|
|
140
|
-
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
|
|
141
|
-
'**/e2e/**',
|
|
142
|
-
],
|
|
143
|
-
projects: [
|
|
144
|
-
{
|
|
145
|
-
extends: true,
|
|
146
|
-
test: {
|
|
147
|
-
name: 'unit',
|
|
148
|
-
include: ['src/**/*.test.unit.ts'],
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
mergeProjectConfig(
|
|
152
|
-
{
|
|
153
|
-
extends: true,
|
|
154
|
-
plugins: [mswHandlersPlugin(root)],
|
|
155
|
-
test: {
|
|
156
|
-
name: 'server',
|
|
157
|
-
include: ['src/**/*.test.ts'],
|
|
158
|
-
exclude: ['src/**/*.test.unit.ts', 'src/**/*.test.tsx'],
|
|
159
|
-
testTimeout: 30_000,
|
|
160
|
-
fileParallelism: false,
|
|
161
|
-
setupFiles: hasLocalSetup ? [localSetup] : [],
|
|
162
|
-
},
|
|
163
|
-
} satisfies TestProjectConfiguration,
|
|
164
|
-
projectOverrides.server ?? {},
|
|
165
|
-
),
|
|
166
|
-
mergeProjectConfig(
|
|
167
|
-
{
|
|
168
|
-
extends: true,
|
|
169
|
-
plugins: [mswHandlersPlugin(root), stylesPlugin(root)],
|
|
170
|
-
test: {
|
|
171
|
-
name: 'browser',
|
|
172
|
-
include: ['src/**/*.test.tsx', 'tests/**/*.test.tsx'],
|
|
173
|
-
setupFiles: [stylesSetup],
|
|
174
|
-
browser: {
|
|
175
|
-
instances: [
|
|
176
|
-
{
|
|
177
|
-
browser: 'chromium',
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
provider: playwright(),
|
|
181
|
-
enabled: true,
|
|
182
|
-
headless: true,
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
} satisfies TestProjectConfiguration,
|
|
186
|
-
projectOverrides.browser ?? {},
|
|
187
|
-
),
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
}),
|
|
191
|
-
overrides,
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const isVitest = process.env.VITEST === 'true'
|
|
196
|
-
|
|
197
|
-
function createFrameworkConfig(root: string) {
|
|
198
|
-
return defineConfig({
|
|
199
|
-
root,
|
|
200
|
-
resolve: {
|
|
201
|
-
tsconfigPaths: true,
|
|
202
|
-
dedupe: ['react', 'react-dom'],
|
|
203
|
-
alias: [
|
|
204
|
-
{ find: '@/mocks', replacement: resolve(root, '__mocks__') },
|
|
205
|
-
{ find: '@', replacement: resolve(root, 'src') },
|
|
206
|
-
],
|
|
207
|
-
},
|
|
208
|
-
ssr: {
|
|
209
|
-
noExternal: ['recharts'],
|
|
210
|
-
},
|
|
211
|
-
plugins: [
|
|
212
|
-
...(isVitest ? [] : [devtools(), nitro(), tanstackStart()]),
|
|
213
|
-
tailwindcss(),
|
|
214
|
-
viteReact(),
|
|
215
|
-
babel({ presets: [reactCompilerPreset()] }),
|
|
216
|
-
svgr({
|
|
217
|
-
include: '**/*.svg',
|
|
218
|
-
svgrOptions: { exportType: 'default' },
|
|
219
|
-
}),
|
|
220
|
-
],
|
|
221
|
-
})
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Creates a full app config with customized test project overrides
|
|
225
|
-
export function createAppConfig(
|
|
226
|
-
root: string,
|
|
227
|
-
projectOverrides: ProjectOverrides = {},
|
|
228
|
-
overrides: TestProjectInlineConfiguration = {},
|
|
229
|
-
) {
|
|
230
|
-
return {
|
|
231
|
-
...workspaceConfig,
|
|
232
|
-
...mergeConfig(
|
|
233
|
-
createFrameworkConfig(root),
|
|
234
|
-
createBaseConfig(root, overrides, projectOverrides),
|
|
235
|
-
),
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Helper to create config from import.meta.url
|
|
240
|
-
export function baseConfigFor(configUrl: string | URL) {
|
|
241
|
-
const root = dirname(fileURLToPath(configUrl))
|
|
242
|
-
return createAppConfig(root)
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Workspace-level Vite+ config shared by monorepo roots.
|
|
246
|
-
export const workspaceConfig = {
|
|
247
|
-
fmt: {
|
|
248
|
-
singleQuote: true,
|
|
249
|
-
semi: false,
|
|
250
|
-
useTabs: true,
|
|
251
|
-
experimentalTailwindcss: {},
|
|
252
|
-
printWidth: 80,
|
|
253
|
-
experimentalSortPackageJson: false,
|
|
254
|
-
proseWrap: 'always',
|
|
255
|
-
ignorePatterns: [
|
|
256
|
-
'**/.vercel',
|
|
257
|
-
'**/.output',
|
|
258
|
-
'**/dist/**',
|
|
259
|
-
'**/env.d.ts',
|
|
260
|
-
'pnpm-lock.yaml',
|
|
261
|
-
'**/routeTree.gen.ts',
|
|
262
|
-
'infra/manifests/gitops/flux-system/gotk-components.yaml',
|
|
263
|
-
'infra/charts/**/templates/**/*.{yml,yaml}',
|
|
264
|
-
'**/charts/**',
|
|
265
|
-
'**/*.yaml',
|
|
266
|
-
'**/*.yml',
|
|
267
|
-
],
|
|
268
|
-
overrides: [
|
|
269
|
-
{
|
|
270
|
-
files: ['*.{yaml,yml}'],
|
|
271
|
-
options: {
|
|
272
|
-
useTabs: false,
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
],
|
|
276
|
-
},
|
|
277
|
-
lint: {
|
|
278
|
-
plugins: [
|
|
279
|
-
'eslint',
|
|
280
|
-
'unicorn',
|
|
281
|
-
'typescript',
|
|
282
|
-
'oxc',
|
|
283
|
-
'react',
|
|
284
|
-
'react-perf',
|
|
285
|
-
'import',
|
|
286
|
-
'jsdoc',
|
|
287
|
-
'jsx-a11y',
|
|
288
|
-
'node',
|
|
289
|
-
'promise',
|
|
290
|
-
],
|
|
291
|
-
categories: {},
|
|
292
|
-
options: {
|
|
293
|
-
typeAware: true,
|
|
294
|
-
typeCheck: true,
|
|
295
|
-
},
|
|
296
|
-
rules: {
|
|
297
|
-
'no-empty-pattern': 'off',
|
|
298
|
-
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
299
|
-
},
|
|
300
|
-
settings: {
|
|
301
|
-
'jsx-a11y': {
|
|
302
|
-
components: {},
|
|
303
|
-
attributes: {},
|
|
304
|
-
},
|
|
305
|
-
react: {
|
|
306
|
-
formComponents: [],
|
|
307
|
-
linkComponents: [],
|
|
308
|
-
},
|
|
309
|
-
jsdoc: {
|
|
310
|
-
ignorePrivate: false,
|
|
311
|
-
ignoreInternal: false,
|
|
312
|
-
ignoreReplacesDocs: true,
|
|
313
|
-
overrideReplacesDocs: true,
|
|
314
|
-
augmentsExtendsReplacesDocs: false,
|
|
315
|
-
implementsReplacesDocs: false,
|
|
316
|
-
exemptDestructuredRootsFromChecks: false,
|
|
317
|
-
tagNamePreference: {},
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
env: {
|
|
321
|
-
builtin: true,
|
|
322
|
-
},
|
|
323
|
-
globals: {},
|
|
324
|
-
ignorePatterns: ['**/dist/**'],
|
|
325
|
-
overrides: [
|
|
326
|
-
{
|
|
327
|
-
files: ['**/*.test.unit.ts'],
|
|
328
|
-
rules: {
|
|
329
|
-
'eslint/no-restricted-imports': [
|
|
330
|
-
'error',
|
|
331
|
-
{
|
|
332
|
-
patterns: [
|
|
333
|
-
{
|
|
334
|
-
group: ['@aamini/config-testing/test/*'],
|
|
335
|
-
message:
|
|
336
|
-
'Unit tests should not import test fixtures. Use plain vitest imports instead.',
|
|
337
|
-
},
|
|
338
|
-
],
|
|
339
|
-
},
|
|
340
|
-
],
|
|
341
|
-
},
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
files: ['**/*.test.tsx'],
|
|
345
|
-
rules: {
|
|
346
|
-
'eslint/no-restricted-imports': [
|
|
347
|
-
'error',
|
|
348
|
-
{
|
|
349
|
-
paths: [
|
|
350
|
-
{
|
|
351
|
-
name: '@aamini/config-testing/test/server',
|
|
352
|
-
message:
|
|
353
|
-
'Browser tests (*.test.tsx) should use test/browser, not test/server.',
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
name: '@aamini/config-testing/test/db',
|
|
357
|
-
message:
|
|
358
|
-
'Browser tests (*.test.tsx) should use test/browser, not test/db.',
|
|
359
|
-
},
|
|
360
|
-
],
|
|
361
|
-
},
|
|
362
|
-
],
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
files: ['**/*.test.ts'],
|
|
367
|
-
rules: {
|
|
368
|
-
'eslint/no-restricted-imports': [
|
|
369
|
-
'error',
|
|
370
|
-
{
|
|
371
|
-
paths: [
|
|
372
|
-
{
|
|
373
|
-
name: '@aamini/config-testing/test/browser',
|
|
374
|
-
message:
|
|
375
|
-
'Server tests (*.test.ts) should use test/server or test/db, not test/browser.',
|
|
376
|
-
},
|
|
377
|
-
],
|
|
378
|
-
},
|
|
379
|
-
],
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
files: ['apps/**'],
|
|
384
|
-
plugins: ['typescript', 'react'],
|
|
385
|
-
rules: {
|
|
386
|
-
'react/self-closing-comp': 'error',
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
files: ['**/*.test.ts', '**/*.test.tsx'],
|
|
391
|
-
plugins: ['typescript', 'vitest'],
|
|
392
|
-
rules: {
|
|
393
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
394
|
-
'vitest/no-standalone-expect': [
|
|
395
|
-
'warn',
|
|
396
|
-
{ additionalTestBlockFunctions: ['test', 'test.skip'] },
|
|
397
|
-
],
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
files: ['**/scripts/**', '**/src/lib/imdb/**'],
|
|
402
|
-
rules: {
|
|
403
|
-
'no-console': 'off',
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
],
|
|
407
|
-
},
|
|
408
|
-
staged: {
|
|
409
|
-
'*.{js,ts,tsx}': 'vp check --fix',
|
|
410
|
-
},
|
|
411
|
-
}
|
package/vitest.shared.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
2
|
-
import viteReact from '@vitejs/plugin-react'
|
|
3
|
-
import { playwright } from '@vitest/browser-playwright'
|
|
4
|
-
import { existsSync } from 'node:fs'
|
|
5
|
-
import { resolve } from 'node:path'
|
|
6
|
-
import type { Plugin } from 'vite'
|
|
7
|
-
import svgr from 'vite-plugin-svgr'
|
|
8
|
-
import {
|
|
9
|
-
defineConfig,
|
|
10
|
-
mergeConfig,
|
|
11
|
-
type TestProjectConfiguration,
|
|
12
|
-
type TestProjectInlineConfiguration,
|
|
13
|
-
type ViteUserConfig,
|
|
14
|
-
} from 'vitest/config'
|
|
15
|
-
|
|
16
|
-
const HANDLER_LOCATIONS = [
|
|
17
|
-
'__mocks__/handlers.ts',
|
|
18
|
-
'__mocks__/handlers.js',
|
|
19
|
-
'src/mocks/handlers.ts',
|
|
20
|
-
'src/mocks/handlers.js',
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
const STYLES_LOCATIONS = ['src/styles.css', 'src/index.css', 'src/app.css']
|
|
24
|
-
|
|
25
|
-
function mswHandlersPlugin(): Plugin {
|
|
26
|
-
const virtualModuleId = '@test/handlers'
|
|
27
|
-
const resolvedVirtualModuleId = '\0' + virtualModuleId
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
name: 'msw-handlers-resolver',
|
|
31
|
-
resolveId(id) {
|
|
32
|
-
if (id === virtualModuleId) {
|
|
33
|
-
return resolvedVirtualModuleId
|
|
34
|
-
}
|
|
35
|
-
return undefined
|
|
36
|
-
},
|
|
37
|
-
load(id) {
|
|
38
|
-
if (id === resolvedVirtualModuleId) {
|
|
39
|
-
const cwd = process.cwd()
|
|
40
|
-
for (const location of HANDLER_LOCATIONS) {
|
|
41
|
-
const fullPath = resolve(cwd, location)
|
|
42
|
-
if (existsSync(fullPath)) {
|
|
43
|
-
return `export { default } from '${fullPath}'`
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
throw new Error(
|
|
47
|
-
`No MSW handlers found. Expected one of:\n${HANDLER_LOCATIONS.map((l) => ` - ${resolve(cwd, l)}`).join('\n')}`,
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
return undefined
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function stylesPlugin(): Plugin {
|
|
56
|
-
const virtualModuleId = '@test/styles'
|
|
57
|
-
const resolvedVirtualModuleId = '\0' + virtualModuleId
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
name: 'styles-resolver',
|
|
61
|
-
resolveId(id) {
|
|
62
|
-
if (id === virtualModuleId) {
|
|
63
|
-
return resolvedVirtualModuleId
|
|
64
|
-
}
|
|
65
|
-
return undefined
|
|
66
|
-
},
|
|
67
|
-
load(id) {
|
|
68
|
-
if (id === resolvedVirtualModuleId) {
|
|
69
|
-
const cwd = process.cwd()
|
|
70
|
-
for (const location of STYLES_LOCATIONS) {
|
|
71
|
-
const fullPath = resolve(cwd, location)
|
|
72
|
-
if (existsSync(fullPath)) {
|
|
73
|
-
return `import '${fullPath}'`
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
throw new Error(
|
|
77
|
-
`No styles file found. Expected one of:\n${STYLES_LOCATIONS.map((l) => ` - ${resolve(cwd, l)}`).join('\n')}`,
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
return undefined
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const stylesSetup = new URL('setup/styles.ts', import.meta.url).pathname
|
|
86
|
-
|
|
87
|
-
function asPlugins(plugins: unknown[]): NonNullable<ViteUserConfig['plugins']> {
|
|
88
|
-
return plugins as NonNullable<ViteUserConfig['plugins']>
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function mergeProjectConfig(
|
|
92
|
-
base: TestProjectConfiguration,
|
|
93
|
-
overrides: TestProjectConfiguration = {},
|
|
94
|
-
): TestProjectConfiguration {
|
|
95
|
-
return mergeConfig(
|
|
96
|
-
base as Record<string, any>,
|
|
97
|
-
overrides as Record<string, any>,
|
|
98
|
-
) as TestProjectConfiguration
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Auto-detect app-level vitest.setup.ts for custom setup (e.g., MSW server)
|
|
102
|
-
const localSetup = resolve(process.cwd(), 'vitest.setup.ts')
|
|
103
|
-
const hasLocalSetup = existsSync(localSetup)
|
|
104
|
-
|
|
105
|
-
interface ProjectOverrides {
|
|
106
|
-
server?: TestProjectConfiguration
|
|
107
|
-
browser?: TestProjectConfiguration
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export const createBaseConfig = (
|
|
111
|
-
overrides: TestProjectInlineConfiguration,
|
|
112
|
-
projectOverrides: ProjectOverrides = {},
|
|
113
|
-
) =>
|
|
114
|
-
mergeConfig(
|
|
115
|
-
defineConfig({
|
|
116
|
-
resolve: {
|
|
117
|
-
tsconfigPaths: true,
|
|
118
|
-
},
|
|
119
|
-
plugins: asPlugins([
|
|
120
|
-
tailwindcss(),
|
|
121
|
-
viteReact({
|
|
122
|
-
babel: {
|
|
123
|
-
plugins: ['babel-plugin-react-compiler'],
|
|
124
|
-
},
|
|
125
|
-
} as Parameters<typeof viteReact>[0]),
|
|
126
|
-
svgr({
|
|
127
|
-
include: '**/*.svg',
|
|
128
|
-
svgrOptions: { exportType: 'default' },
|
|
129
|
-
}),
|
|
130
|
-
]),
|
|
131
|
-
test: {
|
|
132
|
-
passWithNoTests: true,
|
|
133
|
-
projects: [
|
|
134
|
-
{
|
|
135
|
-
extends: true,
|
|
136
|
-
test: {
|
|
137
|
-
name: 'unit',
|
|
138
|
-
include: ['src/**/*.test.unit.ts'],
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
mergeProjectConfig(
|
|
142
|
-
{
|
|
143
|
-
extends: true,
|
|
144
|
-
plugins: [mswHandlersPlugin()],
|
|
145
|
-
test: {
|
|
146
|
-
name: 'server',
|
|
147
|
-
include: ['src/**/*.test.ts'],
|
|
148
|
-
testTimeout: 30_000,
|
|
149
|
-
fileParallelism: false,
|
|
150
|
-
setupFiles: hasLocalSetup ? [localSetup] : [],
|
|
151
|
-
},
|
|
152
|
-
} satisfies TestProjectConfiguration,
|
|
153
|
-
projectOverrides.server ?? {},
|
|
154
|
-
),
|
|
155
|
-
mergeProjectConfig(
|
|
156
|
-
{
|
|
157
|
-
extends: true,
|
|
158
|
-
plugins: [mswHandlersPlugin(), stylesPlugin()],
|
|
159
|
-
test: {
|
|
160
|
-
name: 'browser',
|
|
161
|
-
include: ['src/**/*.test.tsx', 'tests/**/*.test.tsx'],
|
|
162
|
-
setupFiles: [stylesSetup],
|
|
163
|
-
browser: {
|
|
164
|
-
instances: [
|
|
165
|
-
{
|
|
166
|
-
browser: 'chromium',
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
provider: playwright(),
|
|
170
|
-
enabled: true,
|
|
171
|
-
headless: true,
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
} satisfies TestProjectConfiguration,
|
|
175
|
-
projectOverrides.browser ?? {},
|
|
176
|
-
),
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
}),
|
|
180
|
-
overrides,
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
export const baseConfig = createBaseConfig({})
|