Summary
The test infrastructure plan is directionally strong (risk-first tiers, Vitest, in-memory SQLite strategy), but it needs a few concrete additions to avoid test drift and execution blockers.
Strengths
- Clear risk-based sequencing (pure logic before infra-heavy tests)
- Good framework fit (Vitest in a Vite monorepo)
- Pragmatic DB approach (
better-sqlite3 + real migrations)
- Concrete acceptance criteria and implementation intent
Priority Gaps / Risks
- No CI gate for tests
- Add required
pnpm test check in PR workflow immediately.
- Cloudflare/Hono runtime mocking is underspecified
- Define test harness for
c.env bindings (D1/KV/env) and request testing.
- No fixture/factory pattern
- Add shared test fixtures/builders for users/credentials/sessions.
- Durable Objects strategy too vague
- Pick one path (
miniflare or @cloudflare/vitest-pool-workers) and codify setup/teardown.
- Error-path testing underdefined
- Add negative-path tests (401/403/500, invalid tokens, missing resources).
- No integration-flow coverage
- Add at least one thin end-to-end path (login → credential store → callback).
Recommended Changes
1) Add CI enforcement now
- Create
test.yml running pnpm test on PR + push.
- Mark test workflow required before merge.
2) Lock the test harness choices
- Document runtime choice for worker tests (node + mocks vs workers runtime).
- Provide one canonical helper for test app/env construction.
3) Add fixtures + DB isolation utilities
__tests__/fixtures.ts for common entities.
createTestDB() helper with migrations.
- Explicit isolation strategy (fresh DB per test or txn rollback).
4) Re-sequence execution to reduce blockers
Recommended order:
- Errors
- Crypto
- DB helpers
- Credentials service
- OAuth service
- Auth middleware
- Route handlers
- Durable Objects
This Week Plan (Concrete)
Definition of Done (Phase 1)
Summary
The test infrastructure plan is directionally strong (risk-first tiers, Vitest, in-memory SQLite strategy), but it needs a few concrete additions to avoid test drift and execution blockers.
Strengths
better-sqlite3+ real migrations)Priority Gaps / Risks
pnpm testcheck in PR workflow immediately.c.envbindings (D1/KV/env) and request testing.miniflareor@cloudflare/vitest-pool-workers) and codify setup/teardown.Recommended Changes
1) Add CI enforcement now
test.ymlrunningpnpm teston PR + push.2) Lock the test harness choices
3) Add fixtures + DB isolation utilities
__tests__/fixtures.tsfor common entities.createTestDB()helper with migrations.4) Re-sequence execution to reduce blockers
Recommended order:
This Week Plan (Concrete)
Definition of Done (Phase 1)
pnpm testgreen locally and in CI