By the end of this chapter you should be able to setup the base structure of a test environment for an application using Zombie.js and Mocha.
Topics covered in this chapter are:
You'll now be extending the to-do application you started building in the previous chapter and start providing it with the ability to test itself.
In the root of the application, you have a file named package.json
that you already changed to introduce some modules that your application depends on. Now you need to add a new section that specifies the dependencies on other modules during the development and testing phase. This section is named devDependencies
and is only installed by NPM if the NODE_ENV
environment variable is not set to production
. This is a good place to introduce the dependencies on modules that need to be there for running your tests.
First you need to add the mocha
and zombie
modules:
{ "description": "To-do App", "version": "0.0.0", "private": true, "dependencies": { "union": "0.3.0", "flatiron": "0.2.8", "plates": "0.4.x", "node-static": "0.6.0", "nano": "3.3.0", "flatware-cookie-parser": "0.1.x", "flatware-session": "0.1.x" }, "devDependencies": { "mocha": "1.4.x", "zombie": "1.4.x" }, "scripts": { "test": "vows --spec", "start": "node app.js" }, "name": "todo", "author": "Pedro", "homepage": "" }
Then you will need to install these missing dependencies using NPM:
$ npm install ... mocha@1.4.2 node_modules/mocha ... zombie@1.4.1 node_modules/zombie ...
This will install these two modules and their internal dependencies inside the node_modules
folder, making them available for your application at any time.