From the course: JavaScript: Test-Driven Development (ES6)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Resetting the database between tests

Resetting the database between tests - JavaScript Tutorial

From the course: JavaScript: Test-Driven Development (ES6)

Start my 1-month free trial

Resetting the database between tests

- [Instructor] I mentioned in a previous video that an absolutely essential part of effective testing is making sure that our tests are absolutely independent of one another. In other words, the setup, teardown, and production code calls we make in one test should not carry over into any other tests. Otherwise we end up with fragile tests where the results of one test can impact the results of another test, and this can make it very difficult to ensure that our tests are actually testing the right things, and it can also make it difficult to track down what actually went wrong if some of our tests fail. So as it happens, we're currently at risk of violating this rule in our integration test. Look at this resetDatabase call here. If we were to forget this resetDatabase call in one of our tests, this would mean that it could potentially affect other tests that use the users collection in our Mongo database. In this…

Contents