-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.browser.ts
More file actions
67 lines (66 loc) · 2.25 KB
/
vitest.config.browser.ts
File metadata and controls
67 lines (66 loc) · 2.25 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
import { defineConfig } from 'vitest/config';
import path from 'path';
/**
* Vitest Browser Mode Configuration
* Used for testing WASM modules in real browser environment
*
* @see https://vitest.dev/guide/browser/config.html
*/
export default defineConfig({
resolve: {
alias: {
'@veaba/qrcode-js': path.resolve(__dirname, 'packages/qrcode-js/src/index.ts'),
'@veaba/qrcode-js-shared': path.resolve(__dirname, 'packages/qrcode-js-shared/dist/index.js'),
'@veaba/qrcode-wasm': path.resolve(__dirname, 'packages/qrcode-wasm/src/index.ts'),
},
},
test: {
// Browser mode configuration
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
// Use system Chrome/Chromium instead of downloading
providerOptions: {
launch: {
// Auto-detect platform-specific Chrome executable path
...(process.env.CI ? {} : {
executablePath: (() => {
const platform = process.platform;
if (platform === 'win32') {
// Windows Chrome paths (check both common locations)
return process.env.PROGRAMFILES
? `${process.env.PROGRAMFILES}\\Google\\Chrome\\Application\\chrome.exe`
: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe';
}
if (platform === 'darwin') {
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
}
// Linux - use chromium from PATH or let playwright handle it
return undefined;
})(),
}),
args: ['--no-sandbox', '--disable-setuid-sandbox'],
},
headless: !process.env.HEADED,
},
},
// Test files pattern - only browser tests
include: ['tests/**/*.browser.test.{ts,js}'],
exclude: ['**/node_modules/**', '**/dist/**'],
testTimeout: 30000,
hookTimeout: 30000,
},
// Server configuration for serving WASM files
server: {
fs: {
// Allow serving files outside of root (for WASM files)
strict: false,
},
// Configure headers for WASM
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
},
});