因此,当我在本地运行我的仓库中的mocha测试它工作得很好但是当我推送提交并且它在travis CI上运行时我不断收到此错误:
sh: 1: mocha: Permission denied
npm ERR! Test failed. See above for more details.
我的 .travis.yml
language: node_js
node_js:
- "6"
install:
-npm install
before_script: npm install -g mocha
before_script: chmod 0777 ./node_modules/.bin/mocha
的package.json
{
"name": "skeletonapp",
"version": "0.0.0",
"description": "skeletonapp",
"main": "index.js",
"author": {
"name": "li"
},
"scripts": {
"test": "mocha"
},
"dependencies": {
"chai": "^3.5.0",
"mocha": "^3.1.2"
}
}
文件结构
https://travis-ci.org/LiamDotPro/Travis-CI-NodeJS-Skeleton---Mocha-Chai/builds/173340318
test.js
var assert = require('assert');
describe('Array', function () {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
assert.equal(-1, [1, 2, 3].indexOf(4));
});
});
});
2 回答
打开
node_modules/.bin
的执行权限:https://github.com/travis-ci/travis-ci/issues/6828#issuecomment-258581083或者,从Git存储库中删除
node_modules
,然后让Travis使用npm install
进行安装 . (见https://docs.travis-ci.com/user/languages/javascript-with-nodejs#Travis-CI-uses-npm . )不要手动将
mocha
安装到Travis-CI . 它默认在这里 .只需从
.travis.yml
文件中删除before_script
的语句即可 .