goldbergyoni / goldbergyoni/nodejs-testing-best-practices

Rule: test independency

Open
#21 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.4k
Forks
288
PR merge metrics
No merged PRs in 30d

Description

Golden rule - A test visitor will always find the failure reason within the test or at the worst case in the nearest hook.

Practically:
- If the intercepted request affects the test result (e.g. user service returns that 404) - It must be part of the test!
- If the intercepted request is needed for all the tests in the file - Put it in beforeEach
- If there are many intercepted requests and the definition becomes verbose - Extract it to a helper file that is being called by the test file hook

Makes sense?

_Originally posted by @goldbergyoni in https://github.com/testjavascript/integration-tests-a-z/issues/19#issuecomment-726679212_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.