更新:似乎这是 gulp-protractor 中的一个错误。在他们的 github 页面上,他们将其作为错误提交,并将对其进行研究。来源:https ://github.com/mllrsohn/gulp-protractor/issues/64
在解决错误之前,您唯一可行的解决方法是将项目目录更改为不包含空格的目录。
所以我试图让一个 Aurelia 项目开始,包括前端单元测试。这是问题开始的地方。当我尝试运行 e2e gulp 任务时,出现以下错误:
[10:45:44] 使用 gulpfile ~\Documents\Visual Studio 2013\Projects\ProjectX\ProjectX\gulpfile.js
[10:45:44] 开始 'build-e2e'...
[10:45:44] 完成'build-e2e' after 207 ms
[10:45:44] 开始'e2e'...
'C:\Users\jorisd\Documents\Visual' 不被识别为内部或外部命令、可运行程序或批处理文件。
C:\Users\jorisd\Documents\Visual Studio 2013\Projects\ProjectX\ProjectX\build\tasks\e2e.js:34
.on('error', function(e) {throw e; });
错误:量角器以代码 1 退出
基本上它是有问题的突出显示的代码。由于我的路径包含一个空格,它会因为某种原因停在那里。
这是我的 e2e.js 文件现在的样子:
var gulp = require('gulp');
var paths = require('../paths');
var to5 = require('gulp-babel');
var plumber = require('gulp-plumber');
var webdriverUpdate = require('gulp-protractor').webdriver_update;
var webdriverStandalone = require("gulp-protractor").webdriver_standalone;
var protractor = require('gulp-protractor').protractor;
// for full documentation of gulp-protractor,
// please check https://github.com/mllrsohn/gulp-protractor
gulp.task('webdriver-update', webdriverUpdate);
gulp.task('webdriver-standalone', ['webdriver-update'], webdriverStandalone);
// transpiles files in
// /test/e2e/src/ from es6 to es5
// then copies them to test/e2e/dist/
gulp.task('build-e2e', function() {
return gulp.src(paths.e2eSpecsSrc)
.pipe(plumber())
.pipe(to5())
.pipe(gulp.dest(paths.e2eSpecsDist));
});
// runs build-e2e task
// then runs end to end tasks
// using Protractor: http://angular.github.io/protractor/
gulp.task('e2e', ['build-e2e'], function(cb) {
return gulp.src(paths.e2eSpecsDist + '/*.js')
.pipe(protractor({
configFile: '/protractor.conf.js',
args: ['--baseUrl', 'http://127.0.0.1:9000']
}))
.on('end', function() { process.exit(); })
.on('error', function(e) { throw e; });
});
问题在于使用 configFile 选项的 e2e 任务。
我尝试将行更改为以下内容:
configFIle: __dirname + '/protractor.conf.js',
但这也没有结果。如果你们中的任何人知道在 configFile 路径中包含空格的解决方法,我会很高兴听到它。