【问题标题】:Gulp-protractor keep saying "Spec patterns did not match any files"Gulp-protractor 一直说“规范模式与任何文件都不匹配”
【发布时间】:2015-09-29 12:30:44
【问题描述】:

我正在尝试运行用量角器和 jasmine 编写的端到端测试。当我直接致电protractor protractor.config.js 时,它可以完美运行。

但是,当我使用 gulp-protractor 时,我不断收到“规范模式与任何文件不匹配”错误,并且测试无法运行。

这是我的量角器跑步者吞咽任务:

gulp.task('protractor-run', function (done) {
    return gulp.src(["./e2e-tests/**/*-spec.js"])
        .pipe(protractor({
            configFile: "./config/protractor-config.js",
            args: ['--baseUrl', 'http://127.0.0.1:8000']
        }))
        .on('error', function(e) { throw e })
});

这是错误:

WARNING - pattern C:\path\to\app\e2e-tests\login\login-spec.js did not math any files.
[launcher] Process exited with error code 1
C:\path\to\app\node_modules\protractor\node_modules\q\q.js:126
                   throw e;
                   ^

Error: Spec patterns did not match any files.

我错过了什么?

【问题讨论】:

  • 我也有同样的问题,2 秒前在这里问过
  • 更新到最新的 protractor 2.3.0 后有同样的问题。它在更新 (2.2.0) 之前工作。
  • 另见量角器issue #2551

标签: angularjs gulp protractor gulp-protractor


【解决方案1】:

我设法让它工作。通过提供一个空的可读流。然后你在配置文件中指定你的规范文件。

var protractor = require('gulp-protractor').protractor;

gulp.task('protractor', ['webdriverUpdate'],function(){
      return gulp.src([])
          .pipe(protractor({
            configFile: __dirname + '/protractor.conf.js'
          }));
});

也不要忘记 webdriverUpdate

var webdriverUpdate = require('gulp-protractor').webdriver_update;

gulp.task('webdriverUpdate', webdriverUpdate );

在配置文件中:

seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar',

这样我就不再收到错误了。

更新

issue #2551 自 2.5.0 起已关闭并修复

【讨论】:

  • 我也有同样的问题。对我来说主要问题是我的路径中有一个空格“Documents\Visual Studio 2013\...”,由于其中的空间,它不会超过 Visual 位。 __dirname 似乎对我不起作用。但它的方向是正确的。我需要想办法让它使用我的整个目录路径
【解决方案2】:

我在 gulpfile 中解决了这个问题,该文件通过将文件路径放入 gulp.src(['file_path_goes_here']) 的参数中来启动量角器测试。我试图运行的任务在括号之间没有文件路径,并且抛出了错误。

gulp.task('works', 'Run some tests', function() {
  gulp.src(['path/to/test.spec.js'])
    .pipe(protractor({
      configFile: __dirname + '/../test/protractor.conf.js',
      args: ['--baseUrl', 'http://localhost:9099']
    }))
});

gulp.task('error', 'Run feature tests locally', function() {
  gulp.src([''])
    .pipe(protractor({
      configFile: __dirname + '/../test/protractor_local.conf.js',
      args: ['--baseUrl', 'http://localhost:9099']
    }))
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-01
    • 1970-01-01
    • 2017-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-07
    • 2017-02-08
    相关资源
    最近更新 更多