I have got few node packages which works in node.js environment and also in browser. Now I have got two seperate tests (for each environment). What is the best way to run these tests with just npm test
command? Also I want to add these packages to travis.
I'm using mocha
and mocha-phantomjs
.
Node test command
node ./node_modules/mocha/bin/mocha ./test/node/index.js --reporter spec
Browser test command
node ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/index.html
What I tried:
- Add these commands into
npm test
script seperated with semicolon- Problem: When there is an error in first script but no error in second script, command exited with 0 and travis build passed.
- Let node command test in
npm test
script and create custom script for browser tests. Than add these two commands (npm test
andnpm run-script test-browser
) into travis.yml as array.- Problem: Users have to run manually two independent test scripts.
- Let node command test in
npm test
script and add browser tests tonpm posttest
command. Travis.yml will than have got just one script and users will also have to run one script (everyone is happy).- Problem: It just does't feel right, so I wanted to know if there is some better way.