-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvitest.config.mts
More file actions
29 lines (25 loc) · 852 Bytes
/
vitest.config.mts
File metadata and controls
29 lines (25 loc) · 852 Bytes
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
import { env } from 'node:process';
import { configDefaults, defineConfig } from 'vitest/config';
export type Platform = 'browser' | 'node' | 'react-native';
export default defineConfig({
test: {
projects: [getVitestConfig('node')],
},
});
export function getVitestConfig(platform: Platform) {
return defineConfig({
define: {
__BROWSER__: `${platform === 'browser'}`,
__ESM__: 'true',
__NODEJS__: `${platform === 'node'}`,
__REACTNATIVE__: `${platform === 'react-native'}`,
__TEST__: 'true',
__VERSION__: `"${env.npm_package_version}"`,
},
test: {
environment: platform === 'browser' ? 'happy-dom' : 'node',
exclude: [...configDefaults.exclude, '**/e2e/**'],
name: platform,
},
});
}