When we set something up before our tests, we need to be sure we tear it down afterward too. In this video, we’ll use Mocha functions called 'after' and 'afterEach'.
- Mocha provides a "teardown" phase to remove unwanted variables
- If your tests change your development environment, like creating a pretend database, or start up a local server, you can use the teardown block to set your system back to where it started
afterEach()hooks work exactly like
beforeEach(), expect that they happen after
- If you find yourself depending heavily on the teardown phase, you should double-check that you’re testing the right kind of function
You need to sign up for Treehouse in order to download course files.Sign up