我正在尝试将一些Protractor E2E测试绑定到grunt。到目前为止,还没那么成功。我能找到的所有文件都说咕噜声应该适合我的情况。但是,在运行webdriver-manager update --standalone
之后,grunt退出而没有错误消息或运行任何其他任务。
我的Gruntfile:
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
protractor: {
options: {
configFile: "./conf.js", // Default config file
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
args: {
// Arguments passed to the command
}
},
all: {} // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
},
protractor_webdriver: {
update : {
options: {
path:'node_modules/.bin/',
command: ['webdriver-manager update --standalone']
},
},
e2eStart: {
options: {
keepAlive: true,
path:'node_modules/.bin/',
command: ['webdriver-manager start']
},
},
}
});
grunt.registerTask('default', ['protractor_webdriver:update', 'protractor_webdriver:e2eStart', 'protractor:all']);
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.loadNpmTasks('grunt-protractor-runner');
};
因为有人可能很好奇:packages.json
{
"name": "Protractor-me",
"description": "Protractor-me!",
"version": "0.0.1",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-protractor-runner": "~2.0.0",
"grunt-protractor-webdriver": "~0.2.0",
"jasmine-reporters": "^2.0.7"
},
"install": {}
}
最后,grunt --verbose输出
$ grunt --verbose
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Registering "grunt-protractor-webdriver" local Npm module tasks.
Reading /Users/brianalbright/workspace/qa/personal/Brian/Angular/feed_editor_2/node_modules/grunt-protractor-webdriver/package.json...OK
Parsing /Users/brianalbright/workspace/qa/personal/Brian/Angular/feed_editor_2/node_modules/grunt-protractor-webdriver/package.json...OK
Loading "protractor_webdriver.js" tasks...OK
+ protractor_webdriver
Registering "grunt-protractor-runner" local Npm module tasks.
Reading /Users/brianalbright/workspace/qa/personal/Brian/Angular/feed_editor_2/node_modules/grunt-protractor-runner/package.json...OK
Parsing /Users/brianalbright/workspace/qa/personal/Brian/Angular/feed_editor_2/node_modules/grunt-protractor-runner/package.json...OK
Loading "protractor_runner.js" tasks...OK
+ protractor
Loading "Gruntfile.js" tasks...OK
+ default
No tasks specified, running default tasks.
Running tasks: default
Running "default" task
Running "protractor_webdriver:update" (protractor_webdriver) task
Verifying property protractor_webdriver.update exists in config...OK
File: [no files]
Options: path="node_modules/.bin/", command=["webdriver-manager update --standalone"], keepAlive=false
Starting Selenium server
>> selenium standalone is up to date.
>> chromedriver is up to date.
$
它运行webdriver-manager更新,然后停止。我的理解是每个任务应该按顺序运行,而不是停止,直到它结束或错误。我没有想法!
答案 0 :(得分:0)
您可以尝试创建一个调用多个任务的自定义任务,如下所示:
grunt.registerTask('foo', 'My "foo" task.', function() {
// Enqueue "bar" and "baz" tasks, to run after "foo" finishes, in-order.
grunt.task.run('bar', 'baz');
// Or:
grunt.task.run(['bar', 'baz']);
});