Skip to content

Commit d17c439

Browse files
docs(mosaic): add the golden rule of assertions to the testing guide (#10441)
1 parent 553e43c commit d17c439

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

‎packages/mosaic/docs/testing.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ We follow [Write tests. Not too many. Mostly integration.](https://kentcdodds.co
88
a user. Past that point, tests cost more than they return.
99
- **Don't test implementation details.** A test that breaks on a refactor that
1010
keeps the behavior is testing the wrong thing.
11+
- **A test fails if, and only if, the feature stops doing what it is for.**
12+
Before writing or reviewing a test, ask "when will this fail?". If the answer
13+
includes a refactor that keeps the behavior, a renamed helper, or something
14+
the test doesn't control, such as real network or timing, the test is wrong.
15+
See
16+
[The Golden Rule of Assertions](https://www.epicweb.dev/the-golden-rule-of-assertions).
1117
- **Static checks come first.** TypeScript and ESLint catch typos and shape
1218
errors, so tests don't need to.
1319

0 commit comments

Comments
 (0)