Setup for testing in Browser
or else you can use
Here is the boilerplate html for mocha testing. After including your scripts and tests, you can open up in a browser to run tests.
Don’t forget to include
mocha.run() which will initiate the test runner.
Setup for testing in CLI
When it comes to testing, I like CLI more than browser. So here is how you can run your mocha tests from CLI. At first you need to install npm module mocha.
If you are trying to run tests of an web app in the CLI, then you need to find the help of phatomjs or else you can create some tests and try running with
You can specify bdd or tdd using the
Yeoman : generator-mocha
Then boilerplate the setup with the command,
By default yeoman will generate boilerplate for bdd, if you wanna generate for tdd, use the option
--ui as same as for mocha command.
Yeoman will install the mocha, chai etc with the help of bower and help to run tests with grunt-mocha. Yeoman will boilerplate for webapp and grunt-mocha will run the tests with the help of phatomjs.