testinglisted
Install: claude install-skill LDVerdier/rune
# Testing Skill
Write tests that follow the project's established patterns. Every domain function, hook, and user-facing component must be tested.
## Test Layers
### Domain Tests (`app/domain/<feature>.test.ts`)
Pure Vitest tests against pure functions. No React, no DOM, no mocks.
```ts
import { describe, it, expect } from "vitest";
import { myFunction, MY_CONSTANT } from "~/domain/my-feature";
describe("myFunction", () => {
it("returns expected result for valid input", () => {
const result = myFunction(input);
expect(result.score).toBe(4); // comment explaining calculation
});
it("returns null for invalid input", () => {
expect(myFunction(invalid)).toBeNull();
});
});
```
**Rules:**
- Import only from `vitest` and `~/domain/*`
- Use real constants from domain (no mocks)
- Add inline comments explaining non-obvious calculations
- Test edge cases: zero values, max values, null/invalid returns
- Group related tests in `describe` blocks
### Hook Tests (`app/hooks/<hook>.test.ts`)
Use `renderHook` from Testing Library. Wrap state changes in `act()`.
```ts
import { renderHook, act } from "@testing-library/react";
import { describe, it, expect } from "vitest";
import { useMyHook } from "~/hooks/use-my-hook";
describe("useMyHook", () => {
it("has correct initial state", () => {
const { result } = renderHook(() => useMyHook());
expect(result.current.value).toBe(0);
});
it("updates state correctly", () => {
const { result } = renderHo