tdd
Test-driven development with vertical tracer-bullet slices. Use when building test-first, red-green-refactor, or when the user mentions TDD.
- License 许可
- MIT
- 最近更新
- 2026-11-01
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- tdd
- description
- Test-driven development with vertical tracer-bullet slices. Use when building test-first, red-green-refactor, or when the user mentions TDD.
02 资源文件 1
- 参考文档PATTERNS.md4.2 KB
03 SKILL.md 正文
Test-driven development
Vertical RED→GREEN cycles — one behavior per loop, not horizontal "all tests then all code". Aligns with tracer-bullets and verify-after-each-step.
This repo
- Runner split per
docs/architecture.md§ Test matrix:bun test <co-located *.test.ts>—src/**unit tests (core, codecs, backends, TanStack adapters,useHydratedSSR/snapshot contracts). No DOM.bun run test:dom—tests-dom/**/*.test.tsx(vitest + jsdom + @testing-library/react) foruseHydratedrerender / unmount /useSyncExternalStorereactivity.
- Co-locate tests next to the module (
src/core/persist-core.ts→src/core/persist-core.test.ts). - After each GREEN: format/lint/typecheck per
verify-after-each-step. - Mock at the storage backend seam (
StateStorage), never insidepersist-coreor a codec. SeePATTERNS.md.
Workflow
1. Planning
Confirm behaviors to test (not implementation steps) with the user. Prefer deep modules — small public surface (persistSource, createStorage, a codec factory), complex internals.
2. Tracer bullet (within slice)
RED: one test for first behavior → bun test <file> (or test:dom for hydration rerenders)
GREEN: minimal code to pass → re-run
3. Incremental loop
For each behavior: RED → GREEN → run affected tests. One test at a time; no speculative features.
4. Refactor
After GREEN — look for duplication, long methods, shallow modules, feature envy. Run bun test <file> after each step. Never refactor while RED. For production polish on a completed slice, harden-pr lite may run in parallel with tracer-bullet commits.
Checklist per cycle
[ ] Test describes behavior, not implementation
[ ] Test uses the public seam only (persistSource / createStorage / a codec / useHydrated)
[ ] Test would survive an internal refactor
[ ] Code is minimal for this test
[ ] bun test (or test:dom) passes on touched file(s)
Reference
- Good/bad test patterns + mock boundaries:
PATTERNS.md - Slice cadence:
tracer-bullets· Verify:verify-after-each-step
04 同仓库更多 Skills
vue-persist
Gate Vue 3 UI on Persist hydration with useHydrated (shallowRef). Use in setup/effectScope when avoiding flash of default state on async backends.
svelte-store-persist
Gate Svelte store-based UI on Persist hydration with hydratedStore (Readable). Use for Svelte 3–4 or Svelte 5 apps that still use stores; runes UI → svelte-persist.
svelte-persist
Gate Svelte 5 runes UI on Persist hydration with hydratedRune (.current). Use for Svelte 5; for stores / Svelte 3–4 use svelte-store-persist.
solid-persist
Gate Solid UI on Persist hydration with useHydrated (Accessor). Use when avoiding flash of default state on async backends; read hydrated() in reactive scopes.
react-persist
Gate React UI on Persist hydration with useHydrated + toHydrationSignal. Use when avoiding flash of default state on async backends (IndexedDB), SSR snapshot true, or wiring HydrationSignal into React 18/19.
preact-persist
Gate Preact UI on Persist hydration with useHydrated (preact/compat useSyncExternalStore). Use when avoiding flash of default state on async backends or wiring HydrationSignal into Preact.