testingterm 0.0.7 → 0.0.8
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/AGENT-DOCS.md +1 -1
- package/dist/expect.d.ts +6 -0
- package/dist/index.js +25 -0
- package/package.json +5 -5
- package/skill/testingterm/SKILL.md +2 -0
package/AGENT-DOCS.md
CHANGED
|
@@ -53,7 +53,7 @@ themes (every bundled Ghostty theme name)
|
|
|
53
53
|
terminal.verify(statement, { agent, model, effort, interact, timeout, artifacts, soft }) experimental
|
|
54
54
|
terminal.close() -> { video?, profile? }
|
|
55
55
|
|
|
56
|
-
expect(terminal).toHaveText / toHaveScreen / toHaveTitle / toHaveClipboard / toHaveCursorAt / toHaveExited({ code }) (.not works)
|
|
56
|
+
expect(terminal).toHaveText / toHaveScreen / toHaveTitle / toHaveClipboard / toHaveColorAt(point, "#rrggbb", { tolerance }) / toHaveCursorAt / toHaveExited({ code }) (.not works)
|
|
57
57
|
expect(locator).toBeVisible / toHaveCount
|
|
58
58
|
expect(value).toBe / toEqual / toBeTruthy / toContain / toMatch / toBeGreaterThan / toBeLessThan
|
|
59
59
|
|
package/dist/expect.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Locator, type TextQuery } from "./locator.ts";
|
|
2
2
|
import { Terminal } from "./terminal.ts";
|
|
3
|
+
import type { Point } from "./types.ts";
|
|
3
4
|
export declare class AssertionError extends Error {
|
|
4
5
|
readonly screen: string | undefined;
|
|
5
6
|
constructor(message: string, screen?: string);
|
|
@@ -23,6 +24,11 @@ export interface TerminalAssertions {
|
|
|
23
24
|
toHaveClipboard(text: TextQuery, options?: {
|
|
24
25
|
timeout?: number;
|
|
25
26
|
}): Promise<void>;
|
|
27
|
+
/** Waits until the pixel at `point` (screenshot pixels, or the center of a `{ col, row }` cell) is `color` ("#rrggbb"), each channel within `tolerance` (default 0). */
|
|
28
|
+
toHaveColorAt(point: Point, color: string, options?: {
|
|
29
|
+
tolerance?: number;
|
|
30
|
+
timeout?: number;
|
|
31
|
+
}): Promise<void>;
|
|
26
32
|
/** Waits until the cursor is at the cell. */
|
|
27
33
|
toHaveCursorAt(cell: {
|
|
28
34
|
col: number;
|
package/dist/index.js
CHANGED
|
@@ -110,6 +110,31 @@ ${expected}`, await terminal.text());
|
|
|
110
110
|
}, timeout);
|
|
111
111
|
if (!ok) fail(`expected the clipboard ${negated ? "not " : ""}to be ${show(text)}, but it is ${last === null ? "empty (nothing copied)" : JSON.stringify(last)}`);
|
|
112
112
|
},
|
|
113
|
+
async toHaveColorAt(point, color, options) {
|
|
114
|
+
const timeout = timeoutOf(options);
|
|
115
|
+
const tolerance = options?.tolerance ?? 0;
|
|
116
|
+
const match = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
|
|
117
|
+
if (!match) throw new TypeError(`toHaveColorAt needs a color like "#1ec81e", got ${JSON.stringify(color)}`);
|
|
118
|
+
const want = match.slice(1).map((hex2) => parseInt(hex2, 16));
|
|
119
|
+
let x;
|
|
120
|
+
let y;
|
|
121
|
+
if ("col" in point) {
|
|
122
|
+
const { cellWidth, cellHeight, padding } = await terminal.info();
|
|
123
|
+
x = Math.floor(padding + (point.col + 0.5) * cellWidth);
|
|
124
|
+
y = Math.floor(padding + (point.row + 0.5) * cellHeight);
|
|
125
|
+
} else {
|
|
126
|
+
x = Math.floor(point.x);
|
|
127
|
+
y = Math.floor(point.y);
|
|
128
|
+
}
|
|
129
|
+
let seen = [0, 0, 0];
|
|
130
|
+
const ok = await poll(async () => {
|
|
131
|
+
seen = (await terminal.pixels({ region: { x, y, w: 1, h: 1 } })).at(x, y).slice(0, 3);
|
|
132
|
+
return seen.every((value, i) => Math.abs(value - want[i]) <= tolerance) !== negated;
|
|
133
|
+
}, timeout);
|
|
134
|
+
const hex = "#" + seen.map((value) => value.toString(16).padStart(2, "0")).join("");
|
|
135
|
+
const within = tolerance ? ` (\xB1${tolerance} per channel)` : "";
|
|
136
|
+
if (!ok) fail(`expected the pixel at ${x},${y} ${negated ? "not " : ""}to be ${color.toLowerCase()}${within} within ${timeout}ms, but it is ${hex}`);
|
|
137
|
+
},
|
|
113
138
|
async toHaveCursorAt(cell, options) {
|
|
114
139
|
const timeout = timeoutOf(options);
|
|
115
140
|
let last = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testingterm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Test terminal apps: drive a real terminal, read its state, and capture screenshots, videos and profiles",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"zod": "^4.6.7"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@zenbu-labs/testingterm-darwin-arm64": "0.0.
|
|
39
|
-
"@zenbu-labs/testingterm-darwin-x64": "0.0.
|
|
40
|
-
"@zenbu-labs/testingterm-linux-x64": "0.0.
|
|
41
|
-
"@zenbu-labs/testingterm-linux-arm64": "0.0.
|
|
38
|
+
"@zenbu-labs/testingterm-darwin-arm64": "0.0.8",
|
|
39
|
+
"@zenbu-labs/testingterm-darwin-x64": "0.0.8",
|
|
40
|
+
"@zenbu-labs/testingterm-linux-x64": "0.0.8",
|
|
41
|
+
"@zenbu-labs/testingterm-linux-arm64": "0.0.8"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -119,6 +119,8 @@ With one terminal running, commands use it; with several, pass `--id <id>`
|
|
|
119
119
|
- Screenshots: `term.screenshot()` / `testingterm screenshot`.
|
|
120
120
|
- Pixels in a test: `term.pixels({ region })` returns raw RGBA (`at(x, y)` ->
|
|
121
121
|
`[r, g, b, a]`), so you can assert colors and images without decoding PNGs.
|
|
122
|
+
To wait for a color, `await expect(term).toHaveColorAt({ x, y }, "#rrggbb",
|
|
123
|
+
{ tolerance })` retries like the other assertions.
|
|
122
124
|
- Videos: `launch(cmd, { record: true })`, `--video on` on `run`, or `testingterm
|
|
123
125
|
record start|stop`. Videos show the pointer, clicks and keys pressed.
|
|
124
126
|
- Let the human watch live: `--headed` on `run` or `new` opens a window, and
|