Standardize tests on vitest #11

Merged
matt merged 1 commit from mailship-clt-standardize-tests-on-vitest-ddc into main 2026-09-14 17:36:00 +00:00
Collaborator

mailship-clt

Adopt vitest as the standard test framework, replacing hand-rolled assert scripts across 4 test files. This aligns with the nostr/coracle ecosystem (welshman, coracle/harness, NDK all use vitest).

  • vitest setup: Added vitest as a dev dependency (pnpm add -D vitest), created vitest.config.ts with globals: true, and added test/setup.ts to supply required env vars at module load time.
  • Migrated 4 test files from raw JS with custom assert helpers to vitest describe/it/expect as .test.ts:
    • test/digest-template.test.ts — 4 tests verifying {{brandAccent}} usage in the MJML template
    • test/normalize-relay-url.test.ts — 3 tests for guarded normalizeRelayUrl calls (imports from @welshman/util instead of an absolute pnpm path)
    • test/reschedule-on-frequency-change.test.ts — 3 tests for cron rescheduling on frequency change (imports from src/ instead of dist/)
    • test/event-arrival-race.test.ts — 5 tests for the event-arrival race fix (captures fetch IDs before insert to verify delete-by-id, not timestamp-based delete)
  • Deleted test/web-ui.test.js — dead test for the removed web UI (PR #1).
  • package.json: Added "test:unit": "vitest run"; "test" unchanged (bash E2E).
  • script/checks: Added pnpm test:unit after build.
  • README.md: Updated Testing section to document pnpm test:unit and pnpm test (integration).

The integration test suite (test/integration.sh, test/cors.test.sh) is untouched.

How to test: Run pnpm test:unit (or bash script/checks for the full pipeline — typecheck, lint, build, and unit tests). All 4 test files and 15 tests should pass.

mailship-clt Adopt vitest as the standard test framework, replacing hand-rolled assert scripts across 4 test files. This aligns with the nostr/coracle ecosystem (welshman, coracle/harness, NDK all use vitest). - **vitest setup:** Added `vitest` as a dev dependency (`pnpm add -D vitest`), created `vitest.config.ts` with `globals: true`, and added `test/setup.ts` to supply required env vars at module load time. - **Migrated 4 test files** from raw JS with custom assert helpers to vitest `describe`/`it`/`expect` as `.test.ts`: - `test/digest-template.test.ts` — 4 tests verifying `{{brandAccent}}` usage in the MJML template - `test/normalize-relay-url.test.ts` — 3 tests for guarded `normalizeRelayUrl` calls (imports from `@welshman/util` instead of an absolute pnpm path) - `test/reschedule-on-frequency-change.test.ts` — 3 tests for cron rescheduling on frequency change (imports from `src/` instead of `dist/`) - `test/event-arrival-race.test.ts` — 5 tests for the event-arrival race fix (captures fetch IDs before insert to verify delete-by-id, not timestamp-based delete) - **Deleted** `test/web-ui.test.js` — dead test for the removed web UI (PR #1). - **`package.json`:** Added `"test:unit": "vitest run"`; `"test"` unchanged (bash E2E). - **`script/checks`:** Added `pnpm test:unit` after build. - **`README.md`:** Updated Testing section to document `pnpm test:unit` and `pnpm test` (integration). The integration test suite (`test/integration.sh`, `test/cors.test.sh`) is untouched. **How to test:** Run `pnpm test:unit` (or `bash script/checks` for the full pipeline — typecheck, lint, build, and unit tests). All 4 test files and 15 tests should pass.
hudson added 1 commit 2026-09-14 17:34:26 +00:00
- Add vitest as dev dep (pnpm add -D vitest), create vitest.config.ts
  with globals:true and setupFiles
- Migrate digest-template, normalize-relay-url, reschedule-on-frequency-change,
  and event-arrival-race from raw JS + hand-rolled asserts to vitest
  describe/it/expect, as .test.ts (port all assertions without weakening)
- Create test/setup.ts with env vars needed by env.ts/mailer.ts
- DELETE test/web-ui.test.js: dead test for removed web UI (PR #1)
- package.json: add test:unit script (vitest run), keep test = bash E2E
- script/checks: add pnpm test:unit after build
- README: document pnpm test:unit / pnpm test
matt approved these changes 2026-09-14 17:35:56 +00:00
matt merged commit a4bc587d64 into main 2026-09-14 17:36:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: matt/mailship#11
No description provided.