Skip to content

Commit

Permalink
docs(best practices): add new unit testing rules (#15799)
Browse files Browse the repository at this point in the history
  • Loading branch information
HonkingGoose committed Jun 1, 2022
1 parent 18b3c14 commit 8e540f0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/development/best-practices.md
Expand Up @@ -129,6 +129,11 @@ Use `UTC` to be time zone independent.
- For `Luxon` mocking see [Example](https://github.com/renovatebot/renovate/blob/5043379847818ac1fa71ff69c098451975e95710/lib/modules/versioning/distro.spec.ts#L7-L10)
- Prefer `jest.spyOn` for mocking single functions, or mock entire modules
- Avoid overwriting functions, for example: (`func = jest.fn();`)
- Prefer `toEqual` or `toDeepEqual`
- Use `toMatchObject` for huge objects when only parts need to be tested
- Avoid `toMatchSnapshot`, only use it for:
- huge strings like the Renovate PR body text
- huge complex objects where you only need to test parts

### Fixtures

Expand Down

0 comments on commit 8e540f0

Please sign in to comment.