Assertion Best Practices

Use specific assertions (toBeNull, toContain, toHaveLength) over generic ones (toBe, toBeTruthy) Use when writing and organizing tests. Testing category skill.

majiayu000 Updated 567 repo stars

File contents

Assertion Best Practices

Use specific assertions (toBeNull, toContain, toHaveLength) over generic ones (toBe, toBeTruthy). Test one concept per assertion group. Include custom failure messages when the default isn't clear. Avoid asserting implementation details—test observable behavior. Prefer deep equality for objects. Assert negative cases too (doesn't contain, not called).

majiayu000/claude-skill-registry-data/tree/main/testing/assertion-best-practices-omniaffix-dave-sessionguardian commit 64ff2ae9ac

Frequently asked questions

npx skillmds@latest add majiayu000/assertion-best-practices