简体   繁体   English

通过吞咽开始量角器

[英]Starting protractor through gulp

I'm trying to run protractor as a gulp task but I can't get it to work. 我正在尝试将量角器作为一项大任务来运行,但无法正常工作。

I've tried the gulp-protractor plugin like this: 我已经尝试过像这样的gulp-protractor插件:

gulp.task('protractor-server', function (done) {
  var called = false;
  nodemon({
    script: 'test/e2e/server/server.js',
    stdout: true,
    ignore: ['app/**', 'node_modules'],
    watch: 'test/e2e/**/*.js'
  })
  .on('start', function () {
    if (!called) {
      done();
    }
    called = true;
  });
});

gulp.task('run-protractor', ['protractor-server'], function (done) {
  return gulp.src(['test/e2e/**/*.js'])
      .pipe(protractor({
        configFile: __dirname + '/protractor.conf.js'
      }))
      .on('error', function (error) {
        console.log('gulp error: ', error);
        throw error;
      });
});

However, firstly why do I need to use gulp.src(['test/e2e/**/*.js']) and then pipe protractor? 但是,首先为什么我需要使用gulp.src(['test/e2e/**/*.js'])然后使用量角器? Is it not possible to run protractor by it self since i have specified the spec files in the protractor.conf-file. 由于我已经在protractor.conf文件中指定了规范文件,因此无法自行运行量角器。 (fyi I did try that but it didn't work). (仅供参考,我确实尝试过,但是没有用)。

Secondly, when I try and run like specified in the above snippet I keep getting errors like this: WARNING - pattern C:\\[absolutepath]\\test\\e2e\\[subfolder]\\[filename].js did not match any files. 其次,当我尝试按照上述代码片段中的指定运行时,总是收到如下错误消息: WARNING - pattern C:\\[absolutepath]\\test\\e2e\\[subfolder]\\[filename].js did not match any files. for all files that exist in the e2e folder and sub-folders. 适用于e2e文件夹和子文件夹中存在的所有文件。 What could be the reason for this? 这可能是什么原因?

this is my protractor conf file: 这是我的量角器conf文件:

exports.config = {
  specs: [
    'test/e2e/[subfolder]/*.page.js',
    'test/e2e/[subfolder]/*.spec.js'
  ],
  baseUrl: 'http://localhost:3000'

};

If I start the server separately and the run protractor from the command prompt it works fine. 如果我分别启动服务器,并从命令提示符下运行量角器,则可以正常工作。 I was thinking to use child_process.spawn and start a protractor child process but i haven't gotten that to work either. 我当时正在考虑使用child_process.spawn并启动一个量角器子进程,但我也没有使它起作用。 Any suggestions on how to start protractor from a gulp task? 关于如何从吞噬任务开始量角器的任何建议?

No need to use 'test/e2e/**/*.js'] Provide all configuration in protractor.conf.js file it self. 无需使用'test / e2e / ** / *。js']自行在protractor.conf.js文件中提供所有配置。

You can use task like gulp.task('run-protractor', ['run-server','run-webdriver'], function (done) { //run protractor conf here }) 您可以使用诸如gulp.task('run-protractor',['run-server','run-webdriver'],function(done){//在这里运行protractor conf)之类的任务

create run-server and run-webdriver gulp taks, test them separately once they are working, utilize them into run-protractor task. 创建运行服务器和运行Webdriver gulp taks,在它们工作后分别对其进行测试,并将其用于运行量角器任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM