-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathvitest.config.render.ts
More file actions
60 lines (54 loc) · 2.6 KB
/
Copy pathvitest.config.render.ts
File metadata and controls
60 lines (54 loc) · 2.6 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
import os from 'node:os';
import {mergeConfig, defineConfig} from 'vitest/config';
import {playwright} from '@vitest/browser-playwright';
import baseConfig, {isCI, chromiumBrowser} from './vitest.config.base';
import {integrationTests, setupIntegrationTestsMiddlewares, serveDistPlugin, suiteDirs} from './vitest.config.common';
import type {BrowserConfigOptions} from 'vitest/node';
const renderBrowser = process.env.RENDER_BROWSER || 'chromium';
const bundle = process.env.RENDER_BUNDLE || 'esm';
const getAngle = () => {
if (os.platform() === 'darwin' && os.arch() === 'arm64') return '--use-angle=metal';
if (os.platform() === 'win32') return '--use-angle=d3d11';
return '--use-angle=gl';
};
const chromiumArgs = [
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-features=CalculateNativeWinOcclusion',
'--disable-renderer-backgrounding',
'--ash-no-nudges',
getAngle(),
];
if (isCI) chromiumArgs.push('--ignore-gpu-blocklist');
const browsers: Record<string, BrowserConfigOptions> = {
chromium: chromiumBrowser({args: chromiumArgs}),
firefox: {provider: playwright(), headless: false, instances: [{browser: 'firefox'}]},
webkit: {provider: playwright(), instances: [{browser: 'webkit'}]},
};
const browser = browsers[renderBrowser === 'safari' ? 'webkit' : renderBrowser];
export default mergeConfig(baseConfig, defineConfig({
define: {
'import.meta.env.VITE_CI': JSON.stringify(String(isCI)),
'import.meta.env.VITE_UPDATE': JSON.stringify(String(process.env.UPDATE === 'true')),
// Opt-in embedding of passed-test images in the report (local dev only;
// forced off on CI to keep the report small).
'import.meta.env.VITE_EMBED_PASSED_IMAGES': JSON.stringify(String(!isCI && process.env.EMBED_PASSED_IMAGES === 'true')),
'import.meta.env.VITE_SPRITE_FORMAT': process.env.SPRITE_FORMAT != null ? JSON.stringify(process.env.SPRITE_FORMAT) : null,
'import.meta.env.VITE_DIST_BUNDLE': JSON.stringify(bundle),
},
test: {
setupFiles: ['./test/integration/render-tests/setup.ts'],
include: ['test/integration/render-tests/index.test.ts'],
browser: {headless: isCI,
ui: false,
viewport: {width: 1280, height: 720}, ...browser},
},
plugins: [
setupIntegrationTestsMiddlewares({
reportPath: 'test/integration/render-tests/render-tests.html',
}),
integrationTests({suiteDirs: suiteDirs('render-tests'), includeImages: true}),
serveDistPlugin(),
],
}));