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 - JavaScript Tutorial
From the course: JavaScript: Test-Driven Development (ES6)
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Testing database communication: Basic setup3m 49s
-
(Locked)
Database setup and teardown in tests5m 22s
-
(Locked)
Ignoring object properties in Mocha3m 7s
-
(Locked)
Using environment variables in testing2m 29s
-
(Locked)
Creating test helpers5m 9s
-
(Locked)
Resetting the database between tests2m 12s
-
(Locked)
-
-
-