You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use exact assertions in fingerprint tests instead of fuzzy matching
Replace toContain() with toBe() for canonical form assertions. When output
is deterministic, test the exact value. Control inputs by mocking error.stack
to make outputs predictable.
Add testing guidance to CLAUDE.md about preferring exact assertions.
Copy file name to clipboardExpand all lines: CLAUDE.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,6 +175,7 @@ The SDK uses ULID (Universally Unique Lexicographically Sortable Identifier) for
175
175
- Tests use Vitest
176
176
- Some packages have minimal tests (`--passWithNoTests` flag in package.json)
177
177
- Test files are located alongside source files with `.test.ts` extension
178
+
-**Prefer exact assertions over fuzzy matching**: When testing functions that produce stable, canonical output, use exact equality (`toBe`, `toEqual`) rather than fuzzy matchers (`toContain`, `toMatch`). If a value should be stable, test the exact value. For example, instead of `expect(result).toContain('foo')`, use `expect(result).toBe('expected\nfull\nvalue')`. Control inputs (like mocking `error.stack`) to make outputs deterministic.
0 commit comments