A Grunt plugin for running Protractor runner.
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-protractor-runner --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-protractor-runner');
In your project's Gruntfile, add a section named protractor
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
protractor: {
options: {
configFile: "node_modules/protractor/referenceConf.js", // Default config file
keepAlive: true, // If false, the grunt process stops when the test fails.
args: {
// Arguments passed to the command
}
},
your_target: {
configFile: "e2e.conf.js", // Target-specific config file
options: {
args: {} // Target-specific arguments
}
},
},
})
Type: String
Default value: node_modules/protractor/referenceConf.js
A protractor config file.
Type: Boolean
Default value: true
If true, grunt process continues even if the test fails. This option is useful when using with grunt watch. If false, grunt process stops when the test fails.
Type: Boolean
Default value: false
If true, grunt will pass 'debug' as second argument to protractor CLI to enable node CLI debugging as described in Protractor Debugging documentation.
Type: Object
Default value: {}
Arguments passed to the command. Supported arguments are below.
- seleniumAddress
string
: A running selenium address to use - seleniumServerJar
string
: Location of the standalone selenium server .jar file - seleniumPort
string
: Optional port for the standalone selenium server - baseUrl
string
: URL to prepend to all relative paths - rootElement
string
: Element housing ng-app, if not html or body - specs
array
: Array of spec files to test. Ex.["spec1.js","spec2.js"]
- includeStackTrace
boolean
: Print stack trace on error - verbose
boolean
: Print full spec names - browser
string
: Browser name, e.g. chrome or firefox - params
object
: Param object to be passed to the test as browser.params - chromeDriver 'string': The path to the chrome driver (will be passed to the selenium server as a paramter)
After npm install
, you need to run script node_modules/protractor/bin/install_selenium_standalone
to download
selenium to selenium/
.
Then run grunt
or npm test
to test the module. You will encounter these.
- It opens chrome a couple of times without warnings or errors.
- A test task fails but the test process keeps alive and continues to the next test tasks.
- It will launch the node debugger. You'll need to enter c a few times to progress through a few breakpoints, and then when it succeed, press Ctrl-c 2 times to exit the debugger to continue other test tasks.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
- 0.1.7 - Support --browser and --params arguments passed to the protractor command using config in options.args (#12)
- 0.1.6 - Change protractor(peerDependencies) to support version to 0.x (#8, #9, #10)
- 0.1.5 - Added
options.debug
(#7) - 0.1.4 - Change protractor(peerDependencies) to support version to 0.10.x - 0.11.x (#6)
- 0.1.3 - Fixed Windows command
- 0.1.2 - Added keepAlive option.