Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Added support for grep option #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ module.exports = function(grunt) {
}
}
},
testArgsList: {
configFile:"test/testConf.js",
options: {
webdriverManagerUpdate: true,
args: {
grep: '#mytag'
}
}
},
testWithoutArgsList: {
configFile:"test/testConf.js",
options: {
webdriverManagerUpdate: true
}
}
},

// Unit tests.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Supported arguments are below.
* beforeLaunch `string`: You can specify a file containing code to run once configs are read but before any environment setup. This will only run once, and before onPrepare.
* onPrepare `string`: You can specify a file containing code to run once protractor is ready and available, and before the specs are executed. If multiple capabilities are being run, this will run once per capability.
* webDriverProxy `string`: WebDriver proxy configuration to run remote tests
* grep `string`: Grep string used to match the specs to run. EX. `#tag` or `#tag|#tag2`

#### options.output
Type: `String`
Expand Down
2 changes: 1 addition & 1 deletion tasks/protractor_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function(grunt) {

var keepAlive = opts['keepAlive'];
var strArgs = ["seleniumAddress", "seleniumServerJar", "seleniumPort", "baseUrl", "rootElement", "browser", "chromeDriver", "chromeOnly", "directConnect", "sauceUser", "sauceKey", "sauceSeleniumAddress", "framework", "frameworkPath", "beforeLaunch", "onPrepare", "webDriverProxy"];
var listArgs = ["specs", "exclude", "suite"];
var listArgs = ["specs", "exclude", "suite", "grep"];
var boolArgs = ["includeStackTrace", "verbose"];
var objectArgs = ["params", "capabilities", "cucumberOpts", "mochaOpts"];

Expand Down
29 changes: 29 additions & 0 deletions test/listArgs_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var exec = require('child_process').execSync;

exports.testArgsList = function (test) {
var runnerStdOut = exec('grunt protractor:testArgsList --verbose');
if (typeof runnerStdOut === 'object'){
runnerStdOut = runnerStdOut.toString();
}
if (runnerStdOut.indexOf('Spawn node with arguments:') > -1 && runnerStdOut.indexOf('--grep #mytag') > -1) {
test.ok(true, 'grep option test passed');
test.done();
} else {
test.ok(false, 'grep option not found');
test.done();
}
};

exports.testWithoutArgsList = function (test) {
var runnerStdOut = exec('grunt protractor:testWithoutArgsList --verbose');
if (typeof runnerStdOut === 'object'){
runnerStdOut = runnerStdOut.toString();
}
if (runnerStdOut.indexOf('Spawn node with arguments:') > -1 && runnerStdOut.indexOf('--grep') === -1) {
test.ok(true, 'grep option is absent as expected');
test.done();
} else {
test.ok(false, 'grep option should be absent');
test.done();
}
};