-
Notifications
You must be signed in to change notification settings - Fork 407
/
Copy pathvitest.shared.mjs
49 lines (49 loc) · 1.85 KB
/
vitest.shared.mjs
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
import inspector from 'node:inspector';
import process from 'node:process';
import { defineConfig } from 'vitest/config';
import pkg from './package.json';
export default defineConfig({
test: {
// We can't set `NODE_ENV` directly (i.e. `NODE_ENV=production yarn test`), because some packages
// set their env to jsdom, and NODE_ENV=production + jsdom causes `node:` imports to break
env: {
NODE_ENV: process.env.VITE_NODE_ENV,
},
// Don't time out if we detect a debugger attached
testTimeout: inspector.url()
? // Largest allowed delay, see https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value
2147483647
: undefined,
include: ['**/*.{test,spec}.{mjs,js,ts}'],
snapshotFormat: {
printBasicPrototype: true,
callToJSON: true,
},
// To properly resolve `const enum`, we need to point to the TypeScript source files
// See https://github.com/vitest-dev/vitest/discussions/3964
// Using `src` also ensures that the test coverage is accurately reported
alias: Object.fromEntries(
[
'aria-reflection',
'babel-plugin-component',
'compiler',
'errors',
'features',
'module-resolver',
'rollup-plugin',
'shared',
'signals',
'ssr-client-utils',
'ssr-compiler',
'ssr-runtime',
'style-compiler',
'synthetic-shadow',
'template-compiler',
'wire-service',
].map((dep) => [`@lwc/${dep}`, `@lwc/${dep}/src`])
),
},
define: {
'process.env.LWC_VERSION': JSON.stringify(pkg.version),
},
});