-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathvitest.config.ts
More file actions
119 lines (116 loc) · 2.81 KB
/
Copy pathvitest.config.ts
File metadata and controls
119 lines (116 loc) · 2.81 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
import { defineConfig } from 'vitest/config';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { playwright } from '@vitest/browser-playwright';
const fixturesPath = resolve(__dirname, 'test/fixtures');
let fixturesUrl = pathToFileURL(fixturesPath).href;
if (!fixturesUrl.endsWith('/')) {
fixturesUrl += '/';
}
// Node 20 requires vmThreads, newer versions can use threads
const nodeMajor = parseInt(process.version.slice(1).split('.')[0]);
const pool = nodeMajor <= 20 ? 'vmThreads' : 'threads';
export default defineConfig({
resolve: {
alias: {
'@fabricjs/core': resolve(__dirname, './fabric.ts'),
fabric: resolve(__dirname, './fabric.ts'),
},
},
test: {
pool,
clearMocks: true,
mockReset: true,
snapshotSerializers: [
'test/snapshot-serializers/canvas-rendering-context.ts',
],
setupFiles: ['./vitest.setup.ts'],
projects: [
{
extends: true,
test: {
environment: 'jsdom',
environmentOptions: {
jsdom: {
resources: 'usable',
url: fixturesUrl,
},
},
name: 'unit-node',
},
},
{
extends: true,
test: {
browser: {
provider: playwright(),
enabled: true,
headless: true,
instances: [
{
browser: 'chromium',
isolate: true,
},
],
},
name: 'unit-chromium',
},
},
{
extends: true,
test: {
browser: {
provider: playwright({
contextOptions: {
hasTouch: true,
},
}),
enabled: true,
headless: false,
instances: [
{
browser: 'firefox',
isolate: true,
},
],
},
name: 'unit-firefox',
},
},
],
include: [
'src/**/*.test.{ts,tsx}',
'src/**/*.spec.{ts,tsx}',
'extensions/**/*.spec.{ts,tsx}',
'extensions/**/*.test.{ts,tsx}',
'packages/*/src/**/*.spec.{ts,tsx}',
'packages/*/src/**/*.test.{ts,tsx}',
],
coverage: {
reportsDirectory: '.nyc_output',
reporter: [
'text',
'lcov',
['text-summary', { file: 'coverage-summary.txt' }],
],
exclude: [
'test/**',
'dist/**',
'dist-extensions/**',
'src/benchmarks/**',
'vitest*',
'rollup*',
'eslint*',
'playwright*',
'**/node_modules/**',
'.codesandbox/**',
'lib/**',
'packages/e2e/**',
'scripts/**',
'publish-next.js',
'publish.js',
],
provider: 'v8',
},
},
});