Tag: 幻影

如何从node.js中的一个“npm test”命令运行mocha和mocha-phantomjstesting?

我有几个node.js环境和浏览器中的节点包。 现在我有两个单独的testing(针对每个环境)。 用npm test命令运行这些testing的最好方法是什么? 另外我想将这些软件包添加到Travis。 我正在使用mocha和mocha-phantomjs 。 节点testing命令 node ./node_modules/mocha/bin/mocha ./test/node/index.js –reporter spec 浏览器testing命令 node ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/index.html 我试过的: 将这些命令添加到用分号分隔的npm test脚本中 问题:当第一个脚本出现错误,但第二个脚本没有错误时,命令退出0,并通过travis构build。 让节点命令在npm test脚本中testing,并为浏览器testing创build自定义脚本。 将这两个命令( npm test和npm run-script test-browser )添加到travis.yml中作为数组。 问题:用户必须手动运行两个独立的testing脚本。 让节点命令在npm test脚本中npm test ,并将浏览器testing添加到npm posttest命令中。 Travis.yml只会有一个脚本,用户也需要运行一个脚本(每个人都很高兴)。 问题:这只是感觉不对,所以我想知道是否有更好的方法。