any-browser 1.0.5 → 1.0.6
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 +1 -1
- package/src/runner.js +21 -3
package/package.json
CHANGED
package/src/runner.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
2
5
|
import pc from 'picocolors';
|
|
3
6
|
import { resolveBrowsers, ENGINE_LABELS } from './browsers.js';
|
|
4
7
|
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
// The config and tests live inside this package, not in whatever folder the
|
|
12
|
+
// user happens to be running `any-browser` from — so we resolve absolute
|
|
13
|
+
// paths to both instead of letting Playwright guess based on cwd.
|
|
14
|
+
const CONFIG_PATH = join(__dirname, '..', 'playwright.config.js');
|
|
15
|
+
|
|
16
|
+
function resolvePlaywrightCli() {
|
|
17
|
+
const pkgJsonPath = require.resolve('@playwright/test/package.json');
|
|
18
|
+
const pkg = require(pkgJsonPath);
|
|
19
|
+
const binFile = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin.playwright;
|
|
20
|
+
return join(dirname(pkgJsonPath), binFile);
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
export async function runTests(browserArgs, options) {
|
|
6
24
|
const { resolved, unknown } = resolveBrowsers(browserArgs);
|
|
7
25
|
|
|
@@ -29,17 +47,17 @@ function runOne(engine, options) {
|
|
|
29
47
|
return new Promise((resolve) => {
|
|
30
48
|
console.log(pc.bold(`\n▶ ${ENGINE_LABELS[engine]} (${engine})`));
|
|
31
49
|
|
|
32
|
-
const
|
|
50
|
+
const cliPath = resolvePlaywrightCli();
|
|
51
|
+
const args = ['test', `--project=${engine}`, `--config=${CONFIG_PATH}`];
|
|
33
52
|
if (!options.headless) args.push('--headed');
|
|
34
53
|
|
|
35
|
-
const child = spawn(
|
|
54
|
+
const child = spawn(process.execPath, [cliPath, ...args], {
|
|
36
55
|
stdio: 'inherit',
|
|
37
56
|
env: {
|
|
38
57
|
...process.env,
|
|
39
58
|
TEST_URL: options.url,
|
|
40
59
|
TEST_HEADLESS: options.headless ? '1' : '0',
|
|
41
60
|
},
|
|
42
|
-
shell: process.platform === 'win32',
|
|
43
61
|
});
|
|
44
62
|
|
|
45
63
|
child.on('close', (code) => {
|