我有几个节点包可以在node.js环境中运行,也可以在浏览器中运行.现在我有两个单独的测试(针对每个环境).使用npm test命令运行这些测试的最佳方法是什么?另外我想将这些包添加到travis.
我正在使用mocha和mocha-phantomjs.
节点测试命令
node ./node_modules/mocha/bin/mocha ./test/node/index.js --reporter spec
Run Code Online (Sandbox Code Playgroud)
浏览器测试命令
node ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/index.html
Run Code Online (Sandbox Code Playgroud)
我尝试了什么:
npm test以分号分隔的脚本中
npm test脚本中测试并为浏览器测试创建自定义脚本.然后将这两个命令(npm test和npm run-script test-browser)添加到travis.yml作为数组.
npm test脚本中测试并将浏览器测试添加到npm posttest命令.Travis.yml将只有一个脚本,用户也必须运行一个脚本(每个人都很高兴).