( harness: PtyHarness, predicate: (snapshot: TerminalScreenSnapshot) => boolean, timeoutMs = 2_000, )
| 15 | const isMacOsCi = process.platform === "darwin" && env.CI === "true"; |
| 16 | |
| 17 | async function waitForSnapshot( |
| 18 | harness: PtyHarness, |
| 19 | predicate: (snapshot: TerminalScreenSnapshot) => boolean, |
| 20 | timeoutMs = 2_000, |
| 21 | ): Promise<TerminalScreenSnapshot> { |
| 22 | const deadline = Date.now() + timeoutMs; |
| 23 | for (;;) { |
| 24 | const snapshot = harness.snapshot(); |
| 25 | if (predicate(snapshot)) return snapshot; |
| 26 | if (Date.now() > deadline) { |
| 27 | throw new Error( |
| 28 | `Timed out waiting for PTY snapshot: ${JSON.stringify(snapshot.screen.lines)}`, |
| 29 | ); |
| 30 | } |
| 31 | await delay(20); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | test("createTerminalScreen reconstructs visible lines and cursor position", async () => { |
| 36 | const screen = createTerminalScreen({ cols: 10, rows: 3 }); |
no test coverage detected