插件“gulp-mocha”出错

时间:2018-06-10 14:07:13

标签: javascript gulp mocha chai

我想用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` // Вид в котором я хочу отображать результаты тестирования
    }));
});

0 个答案:

没有答案