运行没有gulp.src的Gulp-Angular-Protractor [英] Running Gulp-Angular-Protractor without gulp.src
问题描述
Gulp-Protractor和Gulp-Angular-Protractor可以将args和配置文件传递给量角器。
那么为什么我需要传递一个文件列表来吞咽
函数runProtractor(done){
var params = process.argv;
var args = params.length> 3? [params [3],params [4]]:[];
gutil.log('arguments:'+ args);
$ b gulp.src(paths.e2eFiles)
.pipe(量角器({
configFile:'protractor.local.conf.js',
args:args,
'autoStartStopServer':true,
'debug':true
}))
.on('error',function(err){
gutil.log gutil.colors.red(量角器发生错误,你是否启动webdriver?));
gutil.log(gutil.colors.red(Run cmd'start gulp webdriver'。));
gutil.log(gutil.colors.red('error:'+ err));
//确定失败的测试会导致gulp退出非零
throw err;
)}
.on('end',function(){
//关闭浏览器同步服务器
browserSync.exit();
done();
});
}
问题是量角器没有运行套件,而是src中的文件。有没有办法直接调用量角器?
您可以将gulp.src留空并将规范或套件作为参数传递,文档不是很好的解释它,但我已经能够通过任何配置文件参数,我曾尝试通过吞噬作为arg(我认为我有一个直接连接的问题,因为它是一个布尔值而不是字符串)。
gulp.task('e2e',function(cb){
gulp.src([])。pipe (量角器({
configFile:'./conf/protractor.conf.js',
args:[
'--baseUrl','http:// localhost /',
'--maxSessions',1,
'--suite','./specs/test-spec.js',
'--params.environment','development'$ b $ ('end',cb)
});(b)
})。on('error',function(e){throw e})
.on
};
Gulp-Protractor and Gulp-Angular-Protractor can pass args and a config file to protractor.
So why do I need to pass a list of files to gulp?
function runProtractor(done) {
var params = process.argv;
var args = params.length > 3 ? [params[3], params[4]] : [];
gutil.log('arguments: ' + args);
gulp.src(paths.e2eFiles)
.pipe(protractor({
configFile: 'protractor.local.conf.js',
args: args,
'autoStartStopServer': true,
'debug': true
}))
.on('error', function (err) {
gutil.log(gutil.colors.red("An error occurred in protractor. Did you start the webdriver?"));
gutil.log(gutil.colors.red("Run cmd 'start gulp webdriver'."));
gutil.log(gutil.colors.red('error: ' + err));
// Make sure failed tests cause gulp to exit non-zero
throw err;
})
.on('end', function () {
// Close browser sync server
browserSync.exit();
done();
});
} The problem is that protractor are not running the suites but the files in src. Is there a way to call protractor direct?
You can leave the gulp.src blank and pass the specs or suites as args, the documentation isn't great at explaining it but I have been able to pass any config file argument that I have tried through gulp as an arg (I think i had an issue with direct connect because it's a boolean and not a string).
gulp.task('e2e', function(cb) {
gulp.src([]).pipe(protractor({
configFile: './conf/protractor.conf.js',
args: [
'--baseUrl', 'http://localhost/',
'--maxSessions', 1,
'--suite', './specs/test-spec.js',
'--params.environment', 'development'
]
})).on('error', function(e) { throw e })
.on('end', cb)
});
};
这篇关于运行没有gulp.src的Gulp-Angular-Protractor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!