-
-
Notifications
You must be signed in to change notification settings - Fork 423
Expand file tree
/
Copy pathvitest.config.js
More file actions
102 lines (94 loc) · 2.94 KB
/
Copy pathvitest.config.js
File metadata and controls
102 lines (94 loc) · 2.94 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
import { defineConfig } from 'vitest/config';
import { playwright } from '@vitest/browser-playwright';
import path from 'path';
import nodePolyfills from '@rolldown/plugin-node-polyfills';
import { createVtkPlugins } from './Utilities/build/plugins.mjs';
const noWebGL = !!process.env.NO_WEBGL;
const webGPU = !!process.env.WEBGPU;
const testBrowser = process.env.TEST_BROWSER || 'chromium';
const ci = !!process.env.CI;
const firefoxUserPrefs = {
'dom.webgpu.enabled': true, // off by default on Linux Firefox
'webgl.force-enabled': true, // override GPU blocklist (no real GPU on CI)
'webgl.disable-fail-if-major-performance-caveat': true, // accept llvmpipe
};
const chromiumArgs = ci
? ['--no-sandbox', '--enable-unsafe-swiftshader', '--use-angle=swiftshader']
: [];
if (webGPU) {
// Headless Chromium does not expose a WebGPU adapter by default.
chromiumArgs.push('--enable-unsafe-webgpu');
if (ci) {
chromiumArgs.push(
'--enable-features=Vulkan', // Use Vulkan for the compositor.
'--use-vulkan=swiftshader' // Back Vulkan with SwiftShader on GPU-less CI.
);
}
}
const firefox = {
browser: 'firefox',
headless: false, // supported Vitest Browser option; xvfb-run supplies the display on CI
};
function buildBrowserInstances() {
if (testBrowser === 'firefox') return [firefox];
return [{ browser: 'chromium' }];
}
function buildPlaywrightLaunchOptions() {
if (testBrowser === 'firefox') return { firefoxUserPrefs };
return chromiumArgs.length ? { args: chromiumArgs } : {};
}
export default defineConfig({
resolve: {
alias: {
'vtk.js': path.resolve(import.meta.dirname),
},
},
optimizeDeps: {
include: ['webworker-promise/lib/register'],
rolldownOptions: {
plugins: [nodePolyfills()],
},
},
css: {
modules: {
localsConvention: 'camelCaseOnly',
},
},
define: {
__BASE_PATH__: JSON.stringify(''),
__VTK_TEST_NO_WEBGL__: JSON.stringify(noWebGL),
__VTK_TEST_WEBGPU__: JSON.stringify(webGPU),
global: 'globalThis',
},
plugins: createVtkPlugins({
includeCjson: true,
includeStaticData: true,
staticDataRootDir: import.meta.dirname,
}),
test: {
include: ['Sources/**/test*.js'],
exclude: [
'**/node_modules/**',
'**/dist/**',
'Sources/Testing/testUtils.js',
'Sources/Testing/setupTestEnv.js',
],
setupFiles: ['Sources/Testing/setupTestEnv.js'],
testTimeout: 120000,
reporters: ['default', 'junit'],
outputFile: { junit: 'Utilities/TestResults/junit-report.xml' },
fileParallelism: false, // GPU tests should run sequentially
maxWorkers: 1, // Single worker for GPU resource management
retry: ci ? 1 : 0,
allowOnly: !ci,
browser: {
enabled: true,
headless: true,
screenshotDirectory: 'Utilities/TestResults/screenshots',
provider: playwright({
launchOptions: buildPlaywrightLaunchOptions(),
}),
instances: buildBrowserInstances(),
},
},
});