-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy path.vscode-test.mjs
More file actions
66 lines (57 loc) · 1.61 KB
/
.vscode-test.mjs
File metadata and controls
66 lines (57 loc) · 1.61 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
import { execSync, spawn } from 'node:child_process';
import process from 'node:process';
import { defineConfig } from '@vscode/test-cli';
/** Xvfb display number used for headless Linux testing */
const XVFB_DISPLAY = ':99';
/**
* Ensures Xvfb is running for headless Linux environments (WSL/SSH).
* Mirrors the e2e test approach for consistent behavior across test types.
* Returns the DISPLAY value to use, or undefined if not needed.
*/
function ensureXvfb() {
// Only needed on Linux without a display
if (process.platform !== 'linux' || process.env.DISPLAY) {
return process.env.DISPLAY;
}
try {
// Check if Xvfb is available
execSync('which Xvfb', { stdio: 'ignore' });
// Check if Xvfb is already running on our display
try {
execSync(`xdpyinfo -display ${XVFB_DISPLAY}`, { stdio: 'ignore' });
// Already running
return XVFB_DISPLAY;
} catch {
// Not running, start it
}
// Start Xvfb
const xvfbProcess = spawn('Xvfb', [XVFB_DISPLAY, '-screen', '0', '1920x1080x24'], {
detached: true,
stdio: 'ignore',
});
xvfbProcess.unref();
// Give Xvfb time to start
execSync('sleep 0.5');
console.log(`Started Xvfb on display ${XVFB_DISPLAY}`);
return XVFB_DISPLAY;
} catch {
// Xvfb not available
return undefined;
}
}
// Ensure Xvfb is running before tests start
const display = ensureXvfb();
export default defineConfig([
{
label: 'Unit Tests',
files: 'out/tests/**/*.test.js',
version: 'stable',
launchArgs: ['--disable-extensions', '--disable-gpu'],
env: display ? { DISPLAY: display } : {},
mocha: {
ui: 'tdd',
timeout: 20000,
color: true,
},
},
]);