I'm trying to run my end to end tests written with protractor and jasmine. It works perfectly when I call protractor protractor.config.js
directly.
我正在尝试用量角器和茉莉花来结束测试。当我直接调用量角器protractor.config.js时,它工作得很好。
However, when I use gulp-protractor, I keep getting the "Spec patterns did not match any files" error and the tests do not run.
但是,当我使用gulp-protractor时,我不断得到“Spec模式与任何文件都不匹配”的错误,并且测试不会运行。
This is my protractor runner gulp task:
这是我的量角器转轮gulp任务:
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 })
});
and this is the error:
这是错误:
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.
What am I missing?
我错过了什么?
2 个解决方案
#1
4
I managed to get it working. By providing an empty readable stream. Then you specify your spec files in the config file instead.
我设法让它运作起来。通过提供空的可读流。然后在配置文件中指定spec文件。
var protractor = require('gulp-protractor').protractor;
gulp.task('protractor', ['webdriverUpdate'],function(){
return gulp.src([])
.pipe(protractor({
configFile: __dirname + '/protractor.conf.js'
}));
});
also don't forget the webdriverUpdate
也不要忘记webdriverUpdate
var webdriverUpdate = require('gulp-protractor').webdriver_update;
gulp.task('webdriverUpdate', webdriverUpdate );
and in the config file this:
在配置文件中:
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar',
With this I stopped getting the error.
有了这个我停止了错误。
Update
The issue #2551 is closed and fixed since 2.5.0
问题#2551从2.5.0开始关闭并修复
#2
0
I resolved this in a gulpfile that launches protractor tests by putting a file path into the parameter of gulp.src(['file_path_goes_here']). The task I was trying to run had no file path between the brackets, and was throwing the error.
我在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']
}))
});
#1
4
I managed to get it working. By providing an empty readable stream. Then you specify your spec files in the config file instead.
我设法让它运作起来。通过提供空的可读流。然后在配置文件中指定spec文件。
var protractor = require('gulp-protractor').protractor;
gulp.task('protractor', ['webdriverUpdate'],function(){
return gulp.src([])
.pipe(protractor({
configFile: __dirname + '/protractor.conf.js'
}));
});
also don't forget the webdriverUpdate
也不要忘记webdriverUpdate
var webdriverUpdate = require('gulp-protractor').webdriver_update;
gulp.task('webdriverUpdate', webdriverUpdate );
and in the config file this:
在配置文件中:
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar',
With this I stopped getting the error.
有了这个我停止了错误。
Update
The issue #2551 is closed and fixed since 2.5.0
问题#2551从2.5.0开始关闭并修复
#2
0
I resolved this in a gulpfile that launches protractor tests by putting a file path into the parameter of gulp.src(['file_path_goes_here']). The task I was trying to run had no file path between the brackets, and was throwing the error.
我在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']
}))
});