我有几个在node中工作的node包.js环境和浏览器.现在我有两个独立的测试(针对每个环境).使用npm test
个命令运行这些测试的最佳方式是什么?我还想把这些软件包添加到travis中.
我用mocha
和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:当第一个脚本中有错误,但第二个脚本中没有错误时,命令退出并传递0和travis build.
- 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:个用户必须手动运行两个独立的测试脚本.
- 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).- 感觉不太对劲,所以我想知道是否有更好的方法.