javascript - 插件“gulp-mocha”中的错误
问题描述
我想使用 chai.assert 使用“gulp test”运行测试,并且插件“gulp-mocha”出现错误。'npm start' 工作正常。Webstorm 向我显示此消息:
[16:17:53] 'test' errored after 131 ms
[16:17:53] Error in plugin "gulp-mocha"
Message:
spawn mocha ENOENT
Details:
errno: ENOENT
code: ENOENT
syscall: spawn mocha
path: mocha
spawnargs: /Applications/WebStorm.app/Contents/bin/https:/github.com/AlinaGay/module3_node_js/791559-pixel-hunter/build/test/data/game-data.test.js,--colors,--reporter=spec
stdout:
stderr:
failed: true
signal: null
cmd: mocha /Applications/WebStorm.app/Contents/bin/https:/github.com/AlinaGay/module3_node_js/791559-pixel-hunter/build/test/data/game-data.test.js --colors --reporter=spec
timedOut: false
killed: false
这是测试代码:
import {assert} from 'chai';
describe(`Array`, () => {
describe(`#indexOf()`, () => {
it(`should return -1 when the value is not present`, () => {
assert.equal(-1, [1, 2, 3].indexOf(4));
});
});
});
.eslinter.yml 的代码如下:
parserOptions:
sourceType: 'module'
env:
es6: true
browser: true
commonjs: true
mocha: true
galpfile.js 看起来
.....................
const mocha = require(`gulp-mocha`);
const commonjs = require(`rollup-plugin-commonjs`);
...............................
gulp.task(`test`, function () {
return gulp
.src([`js/**/*.test.js`])
.pipe(rollup({
plugins: [
commonjs() // Сообщает Rollup, что модули можно загружать из node_modules
]}, `cjs`)) // Выходной формат тестов — `CommonJS` модуль
.pipe(gulp.dest(`build/test`))
.pipe(mocha({
reporter: `spec` // Вид в котором я хочу отображать результаты тестирования
}));
});
解决方案
推荐阅读
- python - modbus-tk 得到 Modbus 错误:异常代码 = 3
- r - 如何创建一个从 R 中的另一列连续求和的新列?
- php - Codeigniter Right Join with Where 条件不给出结果
- angular - 避免未使用的资产 Angular
- visual-studio-code - 我的 vs code python 路径显示了 2 个不同的路径?一白一蓝
- r - R data.table - 如何按降序指定变量?
- javascript - 如何解决javascript幻灯片在angularjs路由后不自动显示
- r - R工作室中的小提琴情节
- javascript - Outlook Online 如何下载附件?
- ios - 从 ChildViewController 呈现 UIAlertViewController