Open History to see the last commit
1import { assert, describe, it } from "@effect/vitest";
2import * as Schema from "effect/Schema";
3
4import * as PtyAdapter from "./PtyAdapter.ts";
5
6const isPtySpawnError = Schema.is(PtyAdapter.PtySpawnError);
7
8describe("PtySpawnError", () => {
9 it("derives messages from structural context while preserving the full cause chain", () => {
10 const spawnCause = new Error("spawn /bin/zsh ENOENT");
11 const adapterError = new PtyAdapter.PtySpawnError({
12 adapter: "node-pty",
13 shell: "/bin/zsh",
14 cause: spawnCause,
15 });
16 const managerError = new PtyAdapter.PtySpawnError({
17 adapter: "terminal-manager",
18 attemptedShells: ["/bin/zsh -o nopromptsp", "/bin/bash"],
19 cause: adapterError,
20 });
21
22 assert(isPtySpawnError(managerError));
23 assert.strictEqual(
24 managerError.message,
25 "Failed to spawn PTY process with terminal-manager. Tried shells: /bin/zsh -o nopromptsp, /bin/bash.",
26 );
27 assert.strictEqual(
28 adapterError.message,
29 "Failed to spawn PTY process '/bin/zsh' with node-pty.",
30 );
31 assert.strictEqual(managerError.cause, adapterError);
32 assert.strictEqual(adapterError.cause, spawnCause);
33 });
34});