ptywright 0.3.0 → 0.5.0
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 +76 -31
- package/dist/agent.mjs +2 -2
- package/dist/bin/ptywright.mjs +1 -1
- package/dist/{cli-CfvlbRoZ.mjs → cli-PnG6UR43.mjs} +2390 -2309
- package/dist/cli.mjs +1 -1
- package/dist/config-bGg636EW.mjs +52 -0
- package/dist/config.mjs +2 -0
- package/dist/env-DPYHo-zH.mjs +36 -0
- package/dist/index.mjs +1 -1
- package/dist/manifest_files-DW80c1H7.mjs +77 -0
- package/dist/mcp.mjs +1 -1
- package/dist/pty-cassette.mjs +1 -1
- package/dist/{runner-zi0nItvB.mjs → runner-C1gPRyCM.mjs} +2002 -1038
- package/dist/{runner-zApMYWZx.mjs → runner-wW_DCBX7.mjs} +1576 -1422
- package/dist/script.mjs +1 -1
- package/dist/{server-BC3yo-dq.mjs → server-DMnnXjWv.mjs} +2643 -2527
- package/dist/session.mjs +1 -1
- package/dist/{terminal_session-DopC7Xg6.mjs → terminal_session-DJKr-O3X.mjs} +349 -328
- package/package.json +3 -1
- package/skills/ptywright-testing/SKILL.md +113 -79
- package/skills/ptywright-testing/agents/openai.yaml +4 -0
- package/skills/ptywright-testing/references/agent-regression.md +132 -0
- package/skills/ptywright-testing/references/ci-and-debugging.md +95 -0
- package/skills/ptywright-testing/references/mcp-tools.md +91 -0
- package/skills/ptywright-testing/references/raw-pty-cassettes.md +82 -0
- package/skills/ptywright-testing/references/script-runner.md +80 -0
- package/dist/{pty_like-Cpkh_O9B.mjs → pty_like-BjeBibSL.mjs} +2 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Script Runner
|
|
2
|
+
|
|
3
|
+
Use scripts for deterministic CLI/TUI tests that do not need a browser terminal renderer.
|
|
4
|
+
|
|
5
|
+
## JSON Script
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"$schema": "../schemas/ptywright-script.schema.json",
|
|
10
|
+
"name": "tui_smoke",
|
|
11
|
+
"command": ["bun", "tests/fixtures/tui_demo.ts"],
|
|
12
|
+
"cols": 80,
|
|
13
|
+
"rows": 24,
|
|
14
|
+
"env": { "TERM": "xterm-256color" },
|
|
15
|
+
"steps": [
|
|
16
|
+
{ "type": "waitForText", "text": "Ready", "scope": "buffer" },
|
|
17
|
+
{ "type": "snapshot", "kind": "text", "saveAs": "ready" },
|
|
18
|
+
{ "type": "expectGolden", "name": "ready" }
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Run it:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
ptywright run scripts/tui_smoke.json
|
|
27
|
+
ptywright run scripts/tui_smoke.json --update-goldens
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Run a suite:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
ptywright run-all --dir scripts
|
|
34
|
+
ptywright run-all --dir scripts --update-goldens
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## TypeScript Scripts
|
|
38
|
+
|
|
39
|
+
Use TS scripts when the test needs custom data, helper functions, or custom steps. Keep business logic small. If the script gets complex, move deterministic behavior into a fixture program and keep the ptywright script declarative.
|
|
40
|
+
|
|
41
|
+
## MCP Recording To Script
|
|
42
|
+
|
|
43
|
+
When driving a TUI through MCP tools:
|
|
44
|
+
|
|
45
|
+
1. `start_script_recording(name=...)`
|
|
46
|
+
2. Use normal tools such as `launch_session`, `send_text`, `press_key`, `wait_for_text`, and `snapshot_text`.
|
|
47
|
+
3. Add checkpoints with `mark(label=...)`.
|
|
48
|
+
4. `stop_script_recording(recordingId=..., writeFiles=true)`.
|
|
49
|
+
|
|
50
|
+
The exported script can be committed and replayed without the original agent interaction.
|
|
51
|
+
|
|
52
|
+
## Reports And Artifacts
|
|
53
|
+
|
|
54
|
+
Look for:
|
|
55
|
+
|
|
56
|
+
- `index.html` or `*.report.html`: Timeline report.
|
|
57
|
+
- `*.cast`: Playback stream.
|
|
58
|
+
- `run.summary.json`: Suite/run summary.
|
|
59
|
+
- `failure.last.view.txt`: Last visible terminal state.
|
|
60
|
+
- `failure.last.txt`: Plain last screen.
|
|
61
|
+
- `failure.error.txt`: Error details.
|
|
62
|
+
|
|
63
|
+
## Snapshot Rules
|
|
64
|
+
|
|
65
|
+
- Use `snapshot_text` or text snapshots for stable regression.
|
|
66
|
+
- Use ANSI snapshots only when style information matters.
|
|
67
|
+
- Use masks for random tokens, timestamps, ids, progress counters, and spinner glyphs.
|
|
68
|
+
- Use `scope="buffer"` when content may scroll out of the viewport.
|
|
69
|
+
- Use explicit waits before snapshots. Prefer `waitForText` or stable-screen waits over fixed sleeps.
|
|
70
|
+
|
|
71
|
+
## CI Pattern
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
ptywright run-all --dir scripts
|
|
75
|
+
ptywright script validate .tmp/run-all
|
|
76
|
+
ptywright script commands .tmp/run-all --json
|
|
77
|
+
ptywright script exec .tmp/run-all --command updateGoldens
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Use update commands only for intentional baseline changes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { dirname } from "node:path";
|
|
3
1
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
import { Buffer } from "node:buffer";
|
|
5
5
|
//#region src/pty-cassette/data.ts
|
|
6
6
|
function dataToBytes(data) {
|