any-browser 1.0.6 → 1.0.8
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.
package/package.json
CHANGED
package/playwright.config.js
CHANGED
package/src/postinstall.js
CHANGED
|
@@ -7,9 +7,11 @@ const isCI = !!process.env.CI;
|
|
|
7
7
|
console.log('');
|
|
8
8
|
console.log(pc.cyan('any-browser needs real browser engines (Chromium, Firefox, WebKit) to run tests.'));
|
|
9
9
|
console.log(
|
|
10
|
-
pc.dim(
|
|
10
|
+
pc.dim("Getting a head start on that now (~300MB total, handled by Playwright)")
|
|
11
11
|
);
|
|
12
|
-
console.log(pc.dim(
|
|
12
|
+
console.log(pc.dim("so your first \"any-browser test\" run is fast. If this step gets"));
|
|
13
|
+
console.log(pc.dim('skipped by your npm/security settings, no problem — any-browser'));
|
|
14
|
+
console.log(pc.dim('double-checks and installs whatever it needs the first time you run it.'));
|
|
13
15
|
|
|
14
16
|
if (isCI) {
|
|
15
17
|
console.log(pc.yellow('\nCI environment detected — skipping the automatic download.'));
|
package/src/runner.js
CHANGED
|
@@ -43,14 +43,31 @@ export async function runTests(browserArgs, options) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function
|
|
46
|
+
function ensureBrowserInstalled(engine) {
|
|
47
47
|
return new Promise((resolve) => {
|
|
48
|
-
console.log(pc.bold(`\n▶ ${ENGINE_LABELS[engine]} (${engine})`));
|
|
49
|
-
|
|
50
48
|
const cliPath = resolvePlaywrightCli();
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
// `playwright install <engine>` is cheap and near-instant if the browser
|
|
50
|
+
// is already present — it only actually downloads when something's
|
|
51
|
+
// missing. Running it here means we never depend solely on postinstall
|
|
52
|
+
// having been allowed to run.
|
|
53
|
+
const child = spawn(process.execPath, [cliPath, 'install', engine], {
|
|
54
|
+
stdio: 'inherit',
|
|
55
|
+
});
|
|
56
|
+
child.on('close', () => resolve());
|
|
57
|
+
child.on('error', () => resolve());
|
|
58
|
+
});
|
|
59
|
+
}
|
|
53
60
|
|
|
61
|
+
async function runOne(engine, options) {
|
|
62
|
+
console.log(pc.bold(`\n▶ ${ENGINE_LABELS[engine]} (${engine})`));
|
|
63
|
+
|
|
64
|
+
await ensureBrowserInstalled(engine);
|
|
65
|
+
|
|
66
|
+
const cliPath = resolvePlaywrightCli();
|
|
67
|
+
const args = ['test', `--project=${engine}`, `--config=${CONFIG_PATH}`];
|
|
68
|
+
if (!options.headless) args.push('--headed');
|
|
69
|
+
|
|
70
|
+
await new Promise((resolve) => {
|
|
54
71
|
const child = spawn(process.execPath, [cliPath, ...args], {
|
|
55
72
|
stdio: 'inherit',
|
|
56
73
|
env: {
|
|
@@ -74,4 +91,4 @@ function runOne(engine, options) {
|
|
|
74
91
|
resolve();
|
|
75
92
|
});
|
|
76
93
|
});
|
|
77
|
-
}
|
|
94
|
+
}
|