我正在尝试编写一个代码,使用 jasmine 测试框架和 gulp 测试另一个功能代码但我是 Gulp 领域的新手,我遇到了以下问题,我的代码是:
/*eslint-env node */
const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const eslint = require('gulp-eslint');
const jasmineBrowser = require('gulp-jasmine-browser');
gulp.task('default', ['styles', 'lint'], function() {
gulp.watch('sass/**/*.scss', ['styles']);
gulp.watch('js/**/*.js', ['lint']);
browserSync.init({
server: './'
});
});
gulp.task('styles', function() {
gulp
.src('sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(
autoprefixer({
browsers: ['last 2 versions']
})
)
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream());
});
gulp.task('lint', function() {
return (
gulp
.src(['js/**/*.js'])
// eslint() attaches the lint output to the eslint property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
.pipe(eslint.failOnError())
);
});
gulp.task('tests', function() {
return gulp
.src('tests/spec/extraSpec.js')
.pipe(jasmineBrowser.specRunner({ console: true }))
.pipe(jasmineBrowser.headless({ driver: 'chrome' }));
});
当我在终端中执行以下命令时,gulp tests
我收到此错误消息
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn C:\Users\atlas\Desktop\ud892\Lesson 2\node_modules\gulp-jasmine-browser\lib\runners\chrome_runner ENOENT
这个问题的原因是什么?我该如何解决?考虑到我使用的是 windows7 和,我已经阅读了所有相关的 stackoverflow 帖子,但他们都没有答案。