简体   繁体   中英

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.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? Is it not possible to run protractor by it self since i have specified the spec files in the protractor.conf-file. (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. for all files that exist in the e2e folder and sub-folders. What could be the reason for this?

this is my protractor conf file:

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. 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.

You can use task like gulp.task('run-protractor', ['run-server','run-webdriver'], function (done) { //run protractor conf here })

create run-server and run-webdriver gulp taks, test them separately once they are working, utilize them into run-protractor task.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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