Skip to content

Commit 2e83d9e

Browse files
committed
ci: run unit and e2e tests
1 parent 6716acf commit 2e83d9e

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: CI
22

33
on:
44
push:
5-
branches:
6-
- main
75
pull_request:
86

97
concurrency:
@@ -32,5 +30,8 @@ jobs:
3230
- name: Typecheck
3331
run: pnpm typecheck
3432

35-
- name: Test
36-
run: pnpm run --if-present test
33+
- name: Unit tests
34+
run: pnpm test
35+
36+
- name: E2E tests
37+
run: pnpm test:e2e

.github/workflows/publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ jobs:
4141
- name: Install dependencies
4242
run: pnpm install --frozen-lockfile
4343

44+
- name: Lint
45+
run: pnpm lint
46+
47+
- name: Typecheck
48+
run: pnpm typecheck
49+
50+
- name: Unit tests
51+
run: pnpm test
52+
53+
- name: E2E tests
54+
run: pnpm test:e2e
55+
4456
- name: Get release info
4557
id: release-info
4658
run: |

AGENTS.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,19 @@ During UI tests that require processes to be running, either give the user a pro
1414

1515
## Scripts
1616

17-
- `pnpm typecheck`, `pnpm lint`, `pnpm format`, `pnpm changeset`
17+
- `pnpm typecheck`, `pnpm lint`, `pnpm format`, `pnpm test`, `pnpm test:e2e`, `pnpm changeset`
18+
19+
## Testing
20+
21+
Unit tests live next to the source as `src/**/*.test.ts` and run with `pnpm test`.
22+
23+
Use unit tests for behavior that can be isolated with mocks: registry state, log storage, output parsing, watch matching, event emission, throttling, kill timeout behavior, command parsing, and other pure or narrowly scoped manager internals. Unit tests should stay fast, deterministic, and Pi-independent. Mock child processes, filesystem access, timers, and process-group calls when the test is about manager behavior rather than operating-system behavior.
24+
25+
E2E tests live in `tests/e2e/**/*.e2e.ts` and run with `pnpm test:e2e`. They use `vitest.e2e.config.ts`, real temporary directories, real log files, and real child processes. Use e2e tests when the point is to prove integration with Node process spawning, process groups, stdin/stdout/stderr streams, real filesystem cleanup, executable scripts, shell scripts, Node scripts, or long-running watcher flows. E2E tests must remain Pi-independent and should not import extension UI code.
26+
27+
E2E tests use the fixtures in `tests/e2e/fixtures.ts`. Each test gets a `cwd` temporary directory that is removed with fixture cleanup. Use `addScript(name)` to copy a fixture script into that directory, and `addFile(name, content?)` to create marker/input files during a test. Write commands explicitly in tests, such as `./server.sh`, `bash ./crash-on-file.sh`, or `node ./watcher.mjs`.
28+
29+
Avoid fixed sleeps in both unit and e2e tests. Prefer event-driven helpers that wait for process end, watch matches, output events, or marker-driven script behavior. Use fake timers only for intentional timer behavior in unit tests.
1830

1931
## Structure
2032

0 commit comments

Comments
 (0)