nodejs-integration-tests-best-practices
nodejs-integration-tests-best-practices copied to clipboard
Rule: test independency
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
💪
I'll be sure to include these principles in the readme