Skip to content

An example setup for unit testing JavaScript in the browser with the Mocha testing framework and Chai assertions

License

Notifications You must be signed in to change notification settings

ludofischer/mocha-chai-browser-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A demo setup for unit testing client-side JavaScript code with Mocha.js and Chai.js.

Since mocha 1.2, you can install mocha via npm and run mocha init <path> to generate a client side testing skeleton.

Automated in-browser tests with Karma

This sample also includes a Karma configuration to run the tests automatically.

To use Karma, you need to have node.js and npm installed. In the project directory, type npm install karma-mocha. After the Karma install finishes, type node_modules/karma/bin/karma start and navigate to http://localhost:9876 to let Karma capture the web browser and run the tests automatically.

If you are familiar with npm, you can look at the package.json. That configuration allows you to just type npm install and then npm test to start the Karma server. Since the karma NPM package does not define a bin field, we must make use of the karma-cli package to be able to use the karma executable inside our test script.

About

An example setup for unit testing JavaScript in the browser with the Mocha testing framework and Chai assertions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published