Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run lint
- run: npm test
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `--reporter=tap|auto` flag. `tap` is raw passthrough; `auto` (default)
adds ANSI colorization for TTY stdout and stays raw when piped.
Colorization never alters content — stripping the ANSI codes yields
byte-identical TAP (#7).
- Added support for `playwright` as a `--client` option (#6).

### Changed

- The `tap-parser` dependency is removed. It’s been replaced by a minimal,
internal implementation (#4).
- Library moves to bring-your-own-browser. This means `puppeteer` moved from
`dependencies` to `peerDependencies` with `optional: true` (#5).

Expand Down
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ Required:
Options:
--coverage=<true|false> Enable V8 JS coverage collection. Default: false.
--test-name=<regex> Filter tests by name (regex, matched against full name including describe chain).
--reporter=<tap|auto> Output mode: 'tap' = raw passthrough; 'auto' = colorize when stdout is a TTY. Default: auto.

Environment:
NO_COLOR Any non-empty value disables ANSI colorization (https://no-color.org).
FORCE_COLOR Any non-empty value forces ANSI colorization, even when stdout is not a TTY.

Examples:
x-test --client=puppeteer --url=http://localhost:8080/test/
x-test --client=puppeteer --url=http://localhost:8080/test/ --coverage=true
x-test --client=puppeteer --url=http://localhost:8080/test/ --reporter=tap | faucet
x-test --client=playwright --url=http://localhost:8080/test/ --test-name='^render '
```

Expand Down Expand Up @@ -89,14 +95,24 @@ browser-side runner via the `x-test-name` URL query param.

When `--coverage=true` and the browser exposes V8 coverage (Chromium does), the
CLI collects coverage and hands it to the x-test root for processing.
Playwright and Puppeteer emit coverage in different shapes; the CLI normalizes
Playwright’s raw V8 output to Puppeteer’s `{text, ranges}` shape so the
downstream x-test code sees identical input regardless of client.

### Reporters

The CLI emits TAP14 to stdout.

- `--reporter=tap` — raw passthrough. Use this when piping to another TAP
consumer (CI log collectors, `faucet`, etc.).
- `--reporter=auto` (default) — ANSI colorization when stdout is a TTY, raw when
piped. Stripping the ANSI codes yields byte-identical TAP, so the output is
safe for anything downstream even in auto mode.

Colorization respects [`NO_COLOR`](https://no-color.org) and `FORCE_COLOR`
environment variables.

### Exit code

Non-zero if any test failed, the browser emitted a `Bail out!`, or the driver
crashed. `0` otherwise.
Non-zero if any test failed, the plan didn’t match the asserts seen,
the browser emitted a `Bail out!`, or the driver crashed. `0` otherwise.

## Configuring Playwright

Expand Down
17 changes: 17 additions & 0 deletions demo/color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node
// Pipe a TAP fixture through XTestCliTap with color forced on.
//
// Usage: node demo/color.js <path/to/fixture.tap>

import { readFileSync } from 'node:fs';
import { XTestCliTap } from '../x-test-cli-tap.js';
import { printHelp } from './help.js';

const file = process.argv[2];
if (!file) {
printHelp('demo:color');
process.exit(0);
}

const tap = new XTestCliTap({ stream: process.stdout, color: true });
tap.write(readFileSync(file, 'utf8'));
4 changes: 4 additions & 0 deletions demo/fixtures/bail.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TAP Version 14
ok 1 - first test
ok 2 - second test
Bail out! database connection lost
5 changes: 5 additions & 0 deletions demo/fixtures/basic.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TAP Version 14
ok 1 - adds two numbers
ok 2 - subtracts two numbers
not ok 3 - divides by zero
1..3
8 changes: 8 additions & 0 deletions demo/fixtures/directives.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
TAP Version 14
ok 1 - normal pass
ok 2 - not supported on this platform # SKIP
not ok 3 - feature not built yet # TODO
ok 4 - another pass
ok 5 - quarantined for now # SKIP flaky
ok 6 - surprise, this passed # TODO meant to fail
1..6
20 changes: 20 additions & 0 deletions demo/fixtures/nested.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
TAP Version 14
# Subtest: math
# Subtest: addition
ok 1 - 1 + 1 is 2
ok 2 - 0 + 0 is 0
1..2
ok 1 - addition
# Subtest: subtraction
ok 1 - 2 - 1 is 1
not ok 2 - 1 - 2 is -1 # TODO signed support
1..2
ok 2 - subtraction
1..2
ok 1 - math
# Subtest: strings
ok 1 - concat
ok 2 - length
1..2
ok 2 - strings
1..2
Loading
Loading