Test patterns
A test's job is to fail when the behavior is wrong. Most mediocre tests pass whether the code is right or not.
Rules of thumb
Assert behavior, not implementation
Bad:
expect(spy).toHaveBeenCalled()
Good:
expect(response.body.status).toBe('completed')
expect(db.getUser(id).lastSeenAt).toBe(mockNow)
Spy-assertions fail on refactor and protect nothing. Behavior-assertions fail when the user-visible contract breaks.
One logical check per test
Man
[Description truncada. Veja o README completo no GitHub.]