In my package.json
, I have:
"scripts": {
"test": "mocha --require blanket -R html-cov > test/coverage.html --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'"
},
So if I run npm test
, I get:
npm test
> my-site@1.0.0 test /Users/me/Sites/my-site
> mocha --require blanket -R html-cov > test/coverage.html --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'
If I take out the blanket
stuff ("test": "mocha --compilers coffee:'./node_modules/coffee-script/lib/coffee-script/register'"
), then my tests run correctly.
I am using CoffeeScript
, if that matters. What am I doing incorrectly?
According to the blanket documentation:
If your test runner tests source files written in coffee script, blanket still has you covered. Using a custom loader, coffeescript files are compiled, instrumented, and tested.
The coffee script loader is located in node-loaders/coffee-script.js.
You will need to add the following to your package.json
:
"config": {
"blanket:" {
"pattern" : "src", // use the correct pattern for your project
"loader": "./node-loaders/coffee-script"
}
}
For example see the blanket project package.json file.
In addition, the command line you are using for the tests is incorrect. It is missing the path to your test files and the output redirection should be at the end. You should use something like:
mocha --require blanket -R html-cov --recursive --compilers coffee:./node_modules/coffee-script/lib/coffee-script/register src > test/coverage.html