O'Reilly logo

Web Development with MongoDB and NodeJS - Second Edition by Jason Krol, Bruno Joseph D'mello, Mithun Satheesh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing and running your first test

Up to this point, all of the test code we've seen has just been demos and examples and we haven't actually run any tests. Let's set up the basic structure of our application so that we can start writing real tests.

The first thing to do is set up the folder structure that will house all of our tests. Consider the following steps:

  1. Within the root of the application project folder, create a folder named tests.
  2. Within the tests folder, create three more folders for controllers, models, and server:
    /(existing app root)
    tests/
    ----/controllers/
    ----/models/
    ----/server/

Writing a test helper

Before we start writing the tests for our application, there's a small amount of overhead we need to take care of to prepare for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required