gpt4 book ai didi

node.js - 使用 Protractor webdriver-manager 运行一项任务后 Grunt 停止

转载 作者:太空宇宙 更新时间:2023-11-03 22:34:12 24 4
gpt4 key购买 nike

我目前正在尝试将一些 Protractor E2E 测试绑定(bind)到 grunt 中。到目前为止,还没有那么成功。我能找到的所有文档都说 grunt 应该适合我的情况。但是,运行 webdriver-manager update --standalone 后,grunt 会退出,不会出现错误消息或运行任何其他任务。

我的 Grunt 文件:

'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 更新,然后停止。我的理解是,每个任务都应该按顺序运行,并且在结束或出现错误之前不要停止。我没有主意了!

最佳答案

您可以尝试创建一个调用多个任务的自定义任务,如下所示:

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']);
});

http://gruntjs.com/creating-tasks#custom-tasks

关于node.js - 使用 Protractor webdriver-manager 运行一项任务后 Grunt 停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32081961/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com