tape-six-playwright 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -106,6 +106,8 @@ LLM-friendly documentation is available:
106
106
 
107
107
  The most recent releases:
108
108
 
109
+ - 1.0.3 _Replaced `process.exit()` with `process.exitCode` to prevent truncated output._
110
+ - 1.0.2 _Added `--help`/`-h` and `--version`/`-v` CLI options._
109
111
  - 1.0.1 _Updated dependencies, added `npm run browser` script, improved workflows._
110
112
  - 1.0.0 _The first official release._
111
113
 
@@ -1,10 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import {readFileSync} from 'node:fs';
4
+ import path, {join} from 'node:path';
3
5
  import process from 'node:process';
4
6
  import {fileURLToPath} from 'node:url';
5
7
  import {spawn} from 'node:child_process';
6
8
 
7
- import {getOptions, initReporter, showInfo} from 'tape-six/utils/config.js';
9
+ import {getOptions, initReporter, showInfo, printFlagOptions} from 'tape-six/utils/config.js';
8
10
 
9
11
  import {getReporter, setReporter} from 'tape-six/test.js';
10
12
  import {selectTimer} from 'tape-six/utils/timer.js';
@@ -13,6 +15,11 @@ import TestWorker from '../src/TestWorker.js';
13
15
 
14
16
  const rootFolder = process.cwd();
15
17
 
18
+ const getVersion = () => {
19
+ const pkgPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../package.json');
20
+ return JSON.parse(readFileSync(pkgPath, 'utf8')).version;
21
+ };
22
+
16
23
  const showSelf = () => {
17
24
  const self = new URL(import.meta.url);
18
25
  if (self.protocol === 'file:') {
@@ -23,6 +30,40 @@ const showSelf = () => {
23
30
  process.exit(0);
24
31
  };
25
32
 
33
+ const showVersion = () => {
34
+ console.log('tape6-playwright ' + getVersion());
35
+ process.exit(0);
36
+ };
37
+
38
+ const showHelp = () => {
39
+ console.log(
40
+ 'tape6-playwright ' +
41
+ getVersion() +
42
+ ' \u2014 Playwright-based browser test runner for tape-six\n'
43
+ );
44
+ console.log('Usage: tape6-playwright [options] [patterns...]\n');
45
+ const options = [
46
+ ['--flags, -f <flags>', 'Set reporter flags (env: TAPE6_FLAGS)'],
47
+ ['--par, -p <n>', 'Set parallelism level (env: TAPE6_PAR)'],
48
+ [
49
+ '--server-url, -u <url>',
50
+ 'Server URL (env: TAPE6_SERVER_URL, default: http://localhost:3000)'
51
+ ],
52
+ ['--start-server', 'Auto-start tape6-server'],
53
+ ['--info', 'Show configuration info and exit'],
54
+ ['--self', 'Print the path to this script and exit'],
55
+ ['--help, -h', 'Show this help message and exit'],
56
+ ['--version, -v', 'Show version and exit']
57
+ ];
58
+ console.log('Options:');
59
+ const width = options.reduce((max, [flag]) => Math.max(max, flag.length), 0) + 2;
60
+ for (const [flag, desc] of options) {
61
+ console.log(' ' + flag.padEnd(width) + desc);
62
+ }
63
+ printFlagOptions();
64
+ process.exit(0);
65
+ };
66
+
26
67
  const getServerUrl = () => {
27
68
  if (process.env.TAPE6_SERVER_URL) return process.env.TAPE6_SERVER_URL;
28
69
  const host = process.env.HOST || 'localhost',
@@ -50,17 +91,16 @@ const ensureServer = async (serverUrl, startServer) => {
50
91
  }
51
92
 
52
93
  // start the server
53
- const serverBin = fileURLToPath(
54
- new URL('../node_modules/tape-six/bin/tape6-server.js', import.meta.url)
55
- );
56
- const host = new URL(serverUrl).hostname,
57
- port = new URL(serverUrl).port || '3000';
58
- const child = spawn(process.execPath, [serverBin], {
59
- cwd: rootFolder,
60
- stdio: ['ignore', 'ignore', 'pipe'],
61
- detached: false,
62
- env: {...process.env, HOST: host, PORT: port}
63
- });
94
+ const serverBin = join(rootFolder, 'node_modules/tape-six/bin/tape6-server.js'),
95
+ serverParts = new URL(serverUrl),
96
+ host = serverParts.hostname,
97
+ port = serverParts.port || '3000',
98
+ child = spawn(process.execPath, [serverBin], {
99
+ cwd: rootFolder,
100
+ stdio: ['ignore', 'ignore', 'pipe'],
101
+ detached: false,
102
+ env: {...process.env, HOST: host, PORT: port}
103
+ });
64
104
 
65
105
  let exited = false,
66
106
  exitCode = null,
@@ -100,10 +140,12 @@ const ensureServer = async (serverUrl, startServer) => {
100
140
 
101
141
  const main = async () => {
102
142
  const options = getOptions({
103
- '--self': showSelf,
143
+ '--self': {fn: showSelf, isValueRequired: false},
104
144
  '--start-server': {isValueRequired: false},
105
145
  '--info': {isValueRequired: false},
106
- '--server-url': {aliases: ['-u'], initialValue: getServerUrl(), isValueRequired: true}
146
+ '--server-url': {aliases: ['-u'], initialValue: getServerUrl(), isValueRequired: true},
147
+ '--help': {aliases: ['-h'], fn: showHelp, isValueRequired: false},
148
+ '--version': {aliases: ['-v'], fn: showVersion, isValueRequired: false}
107
149
  });
108
150
  options.flags.serverUrl = options.optionFlags['--server-url'];
109
151
 
@@ -111,7 +153,9 @@ const main = async () => {
111
153
 
112
154
  if (options.optionFlags['--info'] === '') {
113
155
  showInfo(options, []);
114
- process.exit(0);
156
+ await new Promise(r => process.stdout.write('', r));
157
+ process.exitCode = 0;
158
+ return;
115
159
  }
116
160
 
117
161
  const startServer = options.optionFlags['--start-server'] === '';
@@ -185,7 +229,9 @@ const main = async () => {
185
229
 
186
230
  await worker.cleanup();
187
231
 
188
- shutdown(hasFailed ? 1 : 0);
232
+ serverChild?.kill();
233
+ await new Promise(r => process.stdout.write('', r));
234
+ process.exitCode = hasFailed ? 1 : 0;
189
235
  };
190
236
 
191
237
  main().catch(error => console.error('ERROR:', error));
@@ -1,9 +1,48 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import {readFileSync} from 'node:fs';
4
+ import path from 'node:path';
3
5
  import process from 'node:process';
4
6
  import {fileURLToPath} from 'node:url';
5
7
 
6
- if (process.argv.includes('--self')) {
8
+ import {printFlagOptions} from 'tape-six/utils/config.js';
9
+
10
+ const getVersion = () => {
11
+ const pkgPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../package.json');
12
+ return JSON.parse(readFileSync(pkgPath, 'utf8')).version;
13
+ };
14
+
15
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
16
+ console.log(
17
+ 'tape6-playwright ' +
18
+ getVersion() +
19
+ ' \u2014 Playwright-based browser test runner for tape-six\n'
20
+ );
21
+ console.log('Usage: tape6-playwright [options] [patterns...]\n');
22
+ const options = [
23
+ ['--flags, -f <flags>', 'Set reporter flags (env: TAPE6_FLAGS)'],
24
+ ['--par, -p <n>', 'Set parallelism level (env: TAPE6_PAR)'],
25
+ [
26
+ '--server-url, -u <url>',
27
+ 'Server URL (env: TAPE6_SERVER_URL, default: http://localhost:3000)'
28
+ ],
29
+ ['--start-server', 'Auto-start tape6-server'],
30
+ ['--info', 'Show configuration info and exit'],
31
+ ['--self', 'Print the path to this script and exit'],
32
+ ['--help, -h', 'Show this help message and exit'],
33
+ ['--version, -v', 'Show version and exit']
34
+ ];
35
+ console.log('Options:');
36
+ const width = options.reduce((max, [flag]) => Math.max(max, flag.length), 0) + 2;
37
+ for (const [flag, desc] of options) {
38
+ console.log(' ' + flag.padEnd(width) + desc);
39
+ }
40
+ printFlagOptions();
41
+ process.exit(0);
42
+ } else if (process.argv.includes('--version') || process.argv.includes('-v')) {
43
+ console.log('tape6-playwright ' + getVersion());
44
+ process.exit(0);
45
+ } else if (process.argv.includes('--self')) {
7
46
  const self = new URL(import.meta.url);
8
47
  if (self.protocol === 'file:') {
9
48
  console.log(fileURLToPath(self));
package/llms-full.txt CHANGED
@@ -44,7 +44,7 @@ tape6-playwright --start-server --flags FO
44
44
  Runs test files in parallel, each in its own iframe inside headless Chromium.
45
45
 
46
46
  ```bash
47
- tape6-playwright [--flags FLAGS] [--par N] [--start-server] [--server-url URL] [--info] [tests...]
47
+ tape6-playwright [options] [patterns...]
48
48
  ```
49
49
 
50
50
  ### Options
@@ -55,6 +55,8 @@ tape6-playwright [--flags FLAGS] [--par N] [--start-server] [--server-url URL] [
55
55
  - `--server-url URL` (`-u`) — server URL. Overrides `TAPE6_SERVER_URL` and `HOST`/`PORT`.
56
56
  - `--self` — prints the absolute path to `tape6-playwright.js` and exits. Used in cross-runtime scripts.
57
57
  - `--info` — prints runtime, reporter, flags, parallelism, and resolved test files, then exits. Does not require a running server.
58
+ - `--help` (`-h`) — shows help message with all options and flag descriptions, then exits.
59
+ - `--version` (`-v`) — shows version and exits.
58
60
  - Positional arguments: test file glob patterns. If none given, resolved from configuration.
59
61
  - Options accept `--flags FO` or `--flags=FO`. The `=` form does not support quoting.
60
62
 
@@ -156,6 +158,8 @@ The `importmap` section is served by `tape6-server` at `/--importmap` and inject
156
158
 
157
159
  `bin/tape6-playwright.js` is the CLI entry point:
158
160
 
161
+ - With `--help`/`-h`: prints usage and all options, then exits.
162
+ - With `--version`/`-v`: prints version, then exits.
159
163
  - With `--self`: prints its own absolute path and exits.
160
164
  - Otherwise: delegates to `bin/tape6-playwright-node.js`.
161
165
 
@@ -204,7 +208,7 @@ iframe tape-six → ProxyReporter → window.parent.__tape6_reporter(id, event)
204
208
 
205
209
  ## Dependencies
206
210
 
207
- - **`tape-six`** — the core test library. Imports: `State.js`, `utils/EventServer.js`, `utils/config.js` (`getOptions`, `initReporter`, `showInfo`), `test.js`, `utils/timer.js`.
211
+ - **`tape-six`** — the core test library. Imports: `State.js`, `utils/EventServer.js`, `utils/config.js` (`getOptions`, `initReporter`, `showInfo`, `printFlagOptions`), `test.js`, `utils/timer.js`.
208
212
  - **`playwright`** — headless browser automation. Bundled Chromium installed via `postinstall`.
209
213
 
210
214
  ## Writing tests
package/llms.txt CHANGED
@@ -54,7 +54,7 @@ test('DOM test', t => {
54
54
  ## CLI: tape6-playwright
55
55
 
56
56
  ```bash
57
- tape6-playwright [--flags FLAGS] [--par N] [--start-server] [--server-url URL] [--info] [tests...]
57
+ tape6-playwright [options] [patterns...]
58
58
  ```
59
59
 
60
60
  ### Options
@@ -65,6 +65,8 @@ tape6-playwright [--flags FLAGS] [--par N] [--start-server] [--server-url URL] [
65
65
  - `--server-url URL` (`-u`) — server URL (overrides `TAPE6_SERVER_URL`).
66
66
  - `--self` — prints the path to `tape6-playwright.js` (for cross-runtime scripts).
67
67
  - `--info` — prints runtime, reporter, flags, parallelism, and resolved test files, then exits.
68
+ - `--help` (`-h`) — shows help message and exits.
69
+ - `--version` (`-v`) — shows version and exits.
68
70
  - No arguments: runs tests from configuration.
69
71
  - Options accept `--flags FO` or `--flags=FO`. The `=` form does not support quoting.
70
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tape-six-playwright",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Playwright-based browser test runner for tape-six. Runs each test file in its own iframe inside headless Chromium. Works with Node, Deno, and Bun.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -60,7 +60,7 @@
60
60
  ],
61
61
  "dependencies": {
62
62
  "playwright": "^1.58.2",
63
- "tape-six": "^1.7.10"
63
+ "tape-six": "^1.7.13"
64
64
  },
65
65
  "tape6": {
66
66
  "browser": [