testing-essentials
Installation
SKILL.md
Testing Essentials
RULES — Follow these with no exceptions
- Follow the project's existing test setup patterns (e.g. shared setup helpers like
setup :store_test_session) — don't inline DataCase/ConnCase boilerplate that the project already abstracts away - Test both happy path AND error/invalid cases for every function
- Use
async: trueby default; disable it only for real shared state — global state,Application.put_env, named processes, external services. LiveView/ConnCase tests are async-safe under the Ecto SQL Sandbox (Phoenix's own generators emitasync: true). - Define test data in fixtures (
test/support/) — never build it inline across multiple tests - Use
has_element?/2andelement/2for LiveView assertions — nothtml =~ "text"for structure checks - Always test the unauthorized case for any protected resource
- Test the public context interface, not internal implementation details
- Use
describeblocks to group tests by function or behavior
TDD Workflow
Write the failing test first. Run it to confirm it fails for the right reason. Implement the minimum code to make it pass. Never write implementation before the test exists.