Preparing our project to run tests

Now we know what tools we need to run our tests. The next step is to prepare our project to place such tests. Normally during development, we test our application by visiting the pages and interacting with them. We know the result of these actions and we verify if everything is okay. We want to do the same thing with automated tests. However, instead of us repeating the same steps again and again, there will be a script.

In order to make these scripts work, we have to put them in the right context. In other words, they should be executed in the context of our application.

In the previous section, we mentioned Chai (an assertion library) and Mocha (a testing framework). They play well together. So, we will add them ...

Get Node.js By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.