teerapap / grunt-protractor-runner

A Grunt plugin for running protractor runner.
MIT License
149 stars 123 forks source link

:rotating_light: Warning

This repository is DEPRECATED and no longer maintained.

Thank you for all your contributions


grunt-protractor-runner

Build Status

A Grunt plugin for running Protractor runner.

Getting Started

This plugin requires Grunt >=0.4.1.

For Protractor 5.x.x, please use version v5.x.x of this plugin.

For Protractor 4.x.x, please use version v4.x.x of this plugin.

For Protractor 3.x.x, please use version v3.x.x of this plugin.

For Protractor 2.x.x, please use version v2.x.x of this plugin.

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

This plugin will install protractor module locally as a normal dependency. Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-protractor-runner');

Finally you need a Selenium server. If you don't have one set up already, you can install a local standalone version with this command:

./node_modules/grunt-protractor-runner/scripts/webdriver-manager-update

The "protractor" task

Overview

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/example/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
      }
    },
    your_target: {   // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
      options: {
        configFile: "e2e.conf.js", // Target-specific config file
        args: {} // Target-specific arguments
      }
    },
  },
})

Options

options.configFile

Type: String Default value: No default value

A protractor config file.

options.keepAlive

Type: Boolean Default value: false (true before v1.0.0)

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.

options.noColor

Type: Boolean Default value: false

If true, protractor will not give colored output. If false, protractor will give colored output, as it does by default.

options.debug

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.

options.args

Type: Object Default value: {}

Arguments passed to the command. These arguments can also be supplied via command-line too. Ex.grunt protractor --specs=specs/some-test.js or for object options grunt protractor --cucumberOpts={\"tags\":\"@quick\"} or --params='{ "location" : { "href" : "some url" } }'

Passing object argument with --params.xxx.yyy=zzz is not supported at the moment. If you need this behaviour, please join the discussion in #148 .

Supported arguments are below.

options.output

Type: String Default value: false

The file that the task should output the results to.

options.outputOptions

Type: Object Default value: {}

Options for output file. For details see: fs.createWriteStream's options

options.nodeBin

Type: String Default value: node

Path to the node binary file. Useful if node is not on the PATH.

options.webdriverManagerUpdate

Type: Boolean Default value: false

If true, webdriver-manager update will run and install/update selenium driver.

Tests

Run npm install to install dependencies.

Then run grunt or npm test to test the module. You will encounter these.

Contributing

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.

FAQ

Q: Want to global installed protractor?

This plugin installs protractor module locally as a normal dependency.

In case you want to use the plugin with the global installed protractor command. You can do it with these steps below.

Q: Error: Could not find chromedriver at....

You need to install/update selenium webdriver for protractor.

Release History