forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvitest.config.base.ts
79 lines (74 loc) · 1.98 KB
/
vitest.config.base.ts
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
// @ts-nocheck
import {readFile} from 'node:fs/promises';
import {defineConfig} from 'vite';
import {createFilter} from '@rollup/pluginutils';
import arraybuffer from 'vite-plugin-arraybuffer';
function glsl(include: string[]) {
const filter = createFilter(include);
return {
name: 'glsl',
transform(code, id) {
if (!filter(id)) return;
return {
code: `export default ${JSON.stringify(code)};`,
map: {mappings: ''}
};
}
};
}
function fixAssertUtil(regexp = /node_modules\/assert/) {
return {
name: 'fix-assert-util',
setup(build) {
build.onLoad({filter: regexp}, async (args: {path: string}) => {
const source = await readFile(args.path, 'utf8');
return {
contents: source.replace(/util\/'/g, 'util\'').toString(),
loader: 'jsx',
};
});
},
};
}
export default defineConfig({
retry: 2,
pool: 'threads',
poolOptions: {
threads: {
isolate: false,
useAtomics: true,
singleThread: true
}
},
test: {
testTimeout: 5_000,
browser: {
name: 'chromium',
provider: 'playwright',
enabled: true,
headless: true,
slowHijackESM: false,
fileParallelism: false,
},
restoreMocks: true,
unstubGlobals: true,
reporters: process.env.CI ? [
['html', {outputFile: './test/unit/vitest/index.html'}],
['junit', {outputFile: './test/unit/test-results.xml'}],
] : ['basic'],
},
optimizeDeps: {
esbuildOptions: {
plugins: [
fixAssertUtil()
]
},
include: [
'assert'
]
},
plugins: [
glsl(['./src/shaders/*.glsl', './3d-style/shaders/*.glsl']),
arraybuffer(),
],
});