any-browser 1.0.6 → 1.0.7

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "any-browser",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Test your website across Safari (WebKit), Firefox, and Chrome with one CLI command.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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('This is a one-time download (~300MB total, handled by Playwright) so every')
10
+ pc.dim("Getting a head start on that now (~300MB total, handled by Playwright)")
11
11
  );
12
- console.log(pc.dim('"any-browser test <browser>" run afterwards is instant — no setup needed.'));
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.'));
@@ -33,4 +35,4 @@ if (result.status === 0) {
33
35
  console.log(pc.yellow('certain firewalls/proxies, or if disk space is low).'));
34
36
  console.log(pc.dim('Run this once manually, then you\'re good:'));
35
37
  console.log(pc.bold(' npx playwright install chromium firefox webkit\n'));
36
- }
38
+ }
package/src/runner.js CHANGED
@@ -43,14 +43,31 @@ export async function runTests(browserArgs, options) {
43
43
  }
44
44
  }
45
45
 
46
- function runOne(engine, options) {
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
- const args = ['test', `--project=${engine}`, `--config=${CONFIG_PATH}`];
52
- if (!options.headless) args.push('--headed');
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
+ }
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');
53
69
 
70
+ await new Promise((resolve) => {
54
71
  const child = spawn(process.execPath, [cliPath, ...args], {
55
72
  stdio: 'inherit',
56
73
  env: {