-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathvitest.config.ts
More file actions
33 lines (32 loc) · 1.26 KB
/
Copy pathvitest.config.ts
File metadata and controls
33 lines (32 loc) · 1.26 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
import { fileURLToPath } from 'node:url';
import viteReact from '@vitejs/plugin-react';
import { defineConfig } from 'vitest/config';
// Standalone — does NOT extend vite.config.ts. Unit tests run in Node and
// only need path-alias resolution + the React transform for .tsx component
// tests. App-runtime plugins (Cloudflare Vite plugin, content-collections,
// tanstack-start, tailwind, devtools) belong to `vite dev` / `vite build`
// only; pulling them in here breaks vitest (cf-plugin rejects vitest's
// SSR externals) and slows test boot to no benefit.
export default defineConfig({
resolve: {
tsconfigPaths: true,
alias: {
// `cloudflare:*` are Workerd-only virtual modules. Stub them so unit
// tests that transitively import workflow entrypoint classes resolve in
// Node. See src/test/cloudflare-*.stub.ts.
'cloudflare:workers': fileURLToPath(
new URL('./src/test/cloudflare-workers.stub.ts', import.meta.url)
),
'cloudflare:workflows': fileURLToPath(
new URL('./src/test/cloudflare-workflows.stub.ts', import.meta.url)
),
},
},
plugins: [viteReact()],
test: {
include: ['src/**/*.test.{ts,tsx}'],
setupFiles: ['./src/test/setup.ts'],
environment: 'node',
pool: 'forks',
},
});