Getting the application and tests ready to run
Now that we have the Chai assertion library API under our belts, it is time to write and organize the tests. While we have incidentally covered much of this material already, the concise core of a Mocha test infrastructure includes:
Test runner: Configures the overall test run and report
Test suites: One or more organization units grouping many specifications/tests
Setup/Teardown: Setting up a state for each test or suite run
Specifications: Writing the test functions
Starting at the highest level, we look at our test driver web page. As previously discussed, this is where our core application libraries, test libraries, and test specifications are set up and included. All of the Backbone.js application tests in the rest of this chapter are incorporated into the chapters/03/test/test.html
driver page.
The Mocha test runner
The Mocha setup()
function controls the overall parameters and environment for all test suite and specification executions....