This project is a seed for testing front side js by using mocha framework with Grunt in browser or Phantomjs.
So to run this project, grunt & Phantomjs need be installed.
1. git clone https://github.com/wen-bing/mocha-browser-test-seed.git
2. npm install
3. grunt
-
copy test folder to your project dir
-
add the following section to your grunt file
// Project configuration
grunt.initConfig({
mocha: {
all: ['test/**/*.html']
}
});
//load grunt-mocha task
grunt.loadNpmTasks('grunt-mocha');
// Default task.
grunt.registerTask('default', 'mocha');
- add dependency of grunt-mocha to your package.json
"dependencies": {
"grunt-mocha": "0.1.x"
}
grunt mocha
Here are the result:
Running "mocha:all" (mocha) task
Testing sample-test-runner.html....OK
>> 4 assertions passed (0.03s)