nodejs-integration-tests-best-practices icon indicating copy to clipboard operation
nodejs-integration-tests-best-practices copied to clipboard

Rule: test independency

Open mikicho opened this issue 4 years ago • 2 comments

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

mikicho avatar Nov 13 '20 16:11 mikicho

image

mikicho avatar Nov 14 '20 11:11 mikicho

💪

I'll be sure to include these principles in the readme

goldbergyoni avatar Nov 20 '20 07:11 goldbergyoni