This is a React hooks library — all behavior is testable via renderHook.
Cycle
Red
Write a failing test in src/__tests__/<hook-name>.test.ts:
- Cover: hook is defined, mounted state, unmounted state, any side effects
- Use
renderHookfrom@testing-library/react - Run
npm testand confirm it fails for the right reason
Green
Implement the minimum hook code in src/<hook-name>.ts to pass:
- Run
npm testand confirm all tests pass
Refactor
Clean up without breaking tests:
- Run
npm run lintandnpm run test:tscto verify
Reference patterns
- Mount/unmount:
src/__tests__/use-is-mounted-ref.test.ts - Side effects/cleanup:
src/__tests__/use-abort-controller.test.ts