@testivai/witness 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,6 +15,18 @@ export interface LaunchedChrome {
|
|
|
15
15
|
port: number;
|
|
16
16
|
kill: () => void;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Chrome refuses to start as root unless its sandbox is disabled, and root is
|
|
20
|
+
* the default user inside Docker images and CI containers — exactly where
|
|
21
|
+
* `testivai witness <url>` is most useful. Detect that case so the run works
|
|
22
|
+
* instead of timing out with an error that looks like a broken binary.
|
|
23
|
+
*
|
|
24
|
+
* TESTIVAI_CHROME_NO_SANDBOX overrides the detection in both directions, for
|
|
25
|
+
* non-root containers whose seccomp profile still blocks the sandbox.
|
|
26
|
+
*/
|
|
27
|
+
export declare function needsNoSandbox(): boolean;
|
|
28
|
+
/** Flags for the throwaway Chrome instance. Exported for testing. */
|
|
29
|
+
export declare function chromeLaunchArgs(port: number, userDataDir: string): string[];
|
|
18
30
|
/**
|
|
19
31
|
* Launch a throwaway headless Chrome with remote debugging enabled.
|
|
20
32
|
* Uses a temp profile so the user's browser state is never touched.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../../src/standalone/launcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoBH,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAqB1C;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAuBD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../../src/standalone/launcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoBH,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAqB1C;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAMxC;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAqB5E;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAoC5F"}
|
|
@@ -46,6 +46,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
46
46
|
})();
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.findChrome = findChrome;
|
|
49
|
+
exports.needsNoSandbox = needsNoSandbox;
|
|
50
|
+
exports.chromeLaunchArgs = chromeLaunchArgs;
|
|
49
51
|
exports.launchChrome = launchChrome;
|
|
50
52
|
const child_process_1 = require("child_process");
|
|
51
53
|
const fs = __importStar(require("fs"));
|
|
@@ -108,11 +110,25 @@ async function waitForDevtools(port, timeoutMs) {
|
|
|
108
110
|
return false;
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
+
* Chrome refuses to start as root unless its sandbox is disabled, and root is
|
|
114
|
+
* the default user inside Docker images and CI containers — exactly where
|
|
115
|
+
* `testivai witness <url>` is most useful. Detect that case so the run works
|
|
116
|
+
* instead of timing out with an error that looks like a broken binary.
|
|
117
|
+
*
|
|
118
|
+
* TESTIVAI_CHROME_NO_SANDBOX overrides the detection in both directions, for
|
|
119
|
+
* non-root containers whose seccomp profile still blocks the sandbox.
|
|
113
120
|
*/
|
|
114
|
-
|
|
115
|
-
const
|
|
121
|
+
function needsNoSandbox() {
|
|
122
|
+
const forced = process.env.TESTIVAI_CHROME_NO_SANDBOX;
|
|
123
|
+
if (forced === '1' || forced === 'true')
|
|
124
|
+
return true;
|
|
125
|
+
if (forced === '0' || forced === 'false')
|
|
126
|
+
return false;
|
|
127
|
+
// getuid does not exist on Windows.
|
|
128
|
+
return typeof process.getuid === 'function' && process.getuid() === 0;
|
|
129
|
+
}
|
|
130
|
+
/** Flags for the throwaway Chrome instance. Exported for testing. */
|
|
131
|
+
function chromeLaunchArgs(port, userDataDir) {
|
|
116
132
|
const args = [
|
|
117
133
|
`--remote-debugging-port=${port}`,
|
|
118
134
|
`--user-data-dir=${userDataDir}`,
|
|
@@ -123,8 +139,22 @@ async function launchChrome(executable, port) {
|
|
|
123
139
|
'--disable-extensions',
|
|
124
140
|
'--disable-background-networking',
|
|
125
141
|
'--hide-scrollbars',
|
|
126
|
-
'about:blank',
|
|
127
142
|
];
|
|
143
|
+
if (needsNoSandbox()) {
|
|
144
|
+
// Docker gives /dev/shm only 64MB by default, which crashes Chrome on
|
|
145
|
+
// larger pages, so the two container flags travel together.
|
|
146
|
+
args.push('--no-sandbox', '--disable-dev-shm-usage');
|
|
147
|
+
}
|
|
148
|
+
args.push('about:blank');
|
|
149
|
+
return args;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Launch a throwaway headless Chrome with remote debugging enabled.
|
|
153
|
+
* Uses a temp profile so the user's browser state is never touched.
|
|
154
|
+
*/
|
|
155
|
+
async function launchChrome(executable, port) {
|
|
156
|
+
const userDataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'testivai-chrome-'));
|
|
157
|
+
const args = chromeLaunchArgs(port, userDataDir);
|
|
128
158
|
logger_1.logger.debug(`Launching Chrome: ${executable}`);
|
|
129
159
|
const child = (0, child_process_1.spawn)(executable, args, { stdio: 'ignore' });
|
|
130
160
|
const kill = () => {
|
|
@@ -144,8 +174,13 @@ async function launchChrome(executable, port) {
|
|
|
144
174
|
const ready = await waitForDevtools(port, 12000);
|
|
145
175
|
if (!ready) {
|
|
146
176
|
kill();
|
|
177
|
+
const sandboxHint = needsNoSandbox()
|
|
178
|
+
? ''
|
|
179
|
+
: ' If this is a container, Chrome may be refusing to start because its ' +
|
|
180
|
+
'sandbox is unavailable — set TESTIVAI_CHROME_NO_SANDBOX=1.';
|
|
147
181
|
throw new Error(`Chrome did not open its debugging endpoint on port ${port} within 12s. ` +
|
|
148
|
-
`Set TESTIVAI_CHROME_PATH to a working Chrome/Chromium binary if the auto-detected one is broken.`
|
|
182
|
+
`Set TESTIVAI_CHROME_PATH to a working Chrome/Chromium binary if the auto-detected one is broken.` +
|
|
183
|
+
sandboxHint);
|
|
149
184
|
}
|
|
150
185
|
return { port, kill };
|
|
151
186
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.js","sourceRoot":"","sources":["../../src/standalone/launcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBH,gCAqBC;
|
|
1
|
+
{"version":3,"file":"launcher.js","sourceRoot":"","sources":["../../src/standalone/launcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBH,gCAqBC;AAqCD,wCAMC;AAGD,4CAqBC;AAMD,oCAoCC;AApJD,iDAAuE;AACvE,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA6B;AAC7B,4CAAyC;AAEzC,MAAM,SAAS,GAAG;IAChB,8DAA8D;IAC9D,oDAAoD;IACpD,4EAA4E;CAC7E,CAAC;AACF,MAAM,WAAW,GAAG,CAAC,eAAe,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,UAAU,CAAC,CAAC;AAC9F,MAAM,SAAS,GAAG;IAChB,4DAA4D;IAC5D,kEAAkE;CACnE,CAAC;AAEF,SAAgB,UAAU;IACxB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,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YACJ,CAAC,CAAC,uEAAuE;gBACvE,4DAA4D,CAAC;QACjE,MAAM,IAAI,KAAK,CACb,sDAAsD,IAAI,eAAe;YACvE,kGAAkG;YAClG,WAAW,CACd,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testivai/witness",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Local-first visual regression testing: CLI, diff engine, baselines and self-contained HTML report. No account, nothing uploaded.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"chrome-remote-interface": "^0.34.0",
|
|
84
84
|
"commander": "^14.0.3",
|
|
85
85
|
"inquirer": "^8.2.6",
|
|
86
|
-
"ora": "^9.4.
|
|
86
|
+
"ora": "^9.4.1",
|
|
87
87
|
"pngjs": "^7.0.0",
|
|
88
|
-
"ws": "^8.21.
|
|
88
|
+
"ws": "^8.21.3"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@types/inquirer": "^8.2.10",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@types/pngjs": "^6.0.5",
|
|
95
95
|
"@types/ws": "^8.0.0",
|
|
96
96
|
"jest": "^30.4.2",
|
|
97
|
-
"ts-jest": "^29.4.
|
|
97
|
+
"ts-jest": "^29.4.12",
|
|
98
98
|
"typescript": "^6.0.3"
|
|
99
99
|
},
|
|
100
100
|
"engines": {
|