Test your JavaScript code completely
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app/scripts
jenkins
scripts/support
test
.bowerrc
.gitignore
Gruntfile.js
LICENSE
README.md
bower.json
build.xml
package.json

README.md

Testing Browser JavaScript Completely

Testing JavaScript is hard. Testing JavaScript meant for the browser is even harder. There is not any one thing in particular, but building an entire testing ecosystem that plays well with itself and fulfills all the requirements of a modern, robust testing configuration is an immense undertaking. We have been there. We have trialed and erred. We have backtracked. We have hit many more dead ends than I care to talk about.

All of that work has led us here.

Features

  • Mocha, Chai, and Expect based testing framework.
  • RequireJS backed dependency system.
  • PhantomJS AND in-browser testing.
  • Ability to run full test suite or just one file.
  • Code coverage powered by Istanbul.
  • build.xml for getting started with Jenkins.
  • Sample Jenkins config.xml for metrics configuration.

Getting started

To get things ready, just do the following:

git clone https://github.com/jmather/testing-browser-javascript-completely
npm install
grunt bower

Grunt Commands

Command Description
test Run all unit tests
test:browser Run all unit tests in your preferred browser
test:coverage Run code coverage

Now test and test:browser also have an optional argument --file which can be passed a single file. This is quite helpful if you are just trying to finish up a single unit test.

Examples

To run all of your unit tests:

grunt test

To run one unit test:

grunt test --file test/unit/file.test.js

To run all of your unit tests in the browser:

grunt test:browser

To run one unit test in the browser:

grunt test:browser --file test/unit/file.test.js