I have a module, I am testing this module using mocha-phantomjs. I created package.json file
{
"name" : "demo-test",
"scripts": {
"test": "npm run test-debug",
"test-debug": "mocha-phantomjs ./test/Test1.html"
},
"dependencies" : {
"mocha" : "1.13.x",
"commander" : "1.2.x",
"which" : "~1.0.5",
"mocha-phantomjs": "3.3.2"
},
"devDependencies" : {
"chai" : "1.8.x",
"coffee-script" : "1.6.x",
"requirejs" : "2.1.x",
"jquery" : "2.1.0"
}
}
Then I run npm install and then npm test to run the test. It works fine and run the tests of test1.html.
Now I want that all the files (test1, test2, ...) under test directory get executed on running npm test.
I can run all html files by calling then individually in package.json file but if there is a way to load all Html files.
Typically, you would pass a Tests.html file to your mocha-phantomjs runner that would load up all of the test files that you want to run using script tags.
Tests.html would contain:
Alternatively, if you are using RequireJS or another AMD library, you could load one test-init.js file and, within that file, require-in all of the test files individually or in a nested manner as follows:
Tests.html
test-init.js
controller-tests/init.js
service-tests/init.js