Running Gulp-Angular-Protractor without gulp.src

我的梦境 提交于 2019-12-12 05:49:33

问题


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?


回答1:


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)
  });
};


来源:https://stackoverflow.com/questions/38436507/running-gulp-angular-protractor-without-gulp-src

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!