Skip to content

Commit 0465225

Browse files
committed
chore(instructions): define rules about using conditional mocks over called-with assertions
1 parent dc9aedc commit 0465225

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ describe('Config Loader', () => {
113113
- Ensure all code paths have corresponding tests
114114
- Test happy paths, unhappy paths, and edge cases
115115
- Never modify tests to pass without understanding root cause
116+
- When a mock returns/resolves a value, do not assert that the mock was called (or was called with specific arguments).
117+
Instead, leverage `vitest-when` to make the mock return different values based on the arguments it is called with, and assert the expected result of the function under test.
118+
This ensures the test is focused on the behavior of the function under test rather than coupling it to specific implementation details of how it interacts with its dependencies.
119+
- If a mock does not return/resolve a value and only has side-effects, consider whether it's behavior could be adjusted to return a value that can be asserted instead of asserting the mock call directly.
116120

117121
## Dependencies
118122

0 commit comments

Comments
 (0)