Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Eslint Plugin Protractor | 51 | 56 | 36 | 2 years ago | 68 | September 18, 2019 | 15 | mit | JavaScript | |
ESLint rules for Protractor | ||||||||||
Protractor Starter | 38 | 4 years ago | 1 | mit | JavaScript | |||||
#archived: protractor-starter end-to-end tests setup also for non angular application | ||||||||||
Angular Material Boilerplate | 30 | 3 years ago | 1 | mit | JavaScript | |||||
A straightforward and well structured boilerplate based on Google's Angular Material project. | ||||||||||
Demo Web Client | 2 | 5 years ago | apache-2.0 | JavaScript | ||||||
A web client demo | ||||||||||
Common Web Client | 2 | 2 years ago | 6 | apache-2.0 | JavaScript | |||||
A common react web client | ||||||||||
Protractor Cucumber Serenity Typescript Starter | 2 | 3 years ago | mit | TypeScript | ||||||
:snowman: Protractor cucumber boilerplate with serenity reporting with extensive react support | ||||||||||
Reactive React Seed | 1 | 7 years ago | JavaScript | |||||||
ESLint rules for Protractor
This plugin would not only help catch common Protractor-specific errors early, follow the best practices for writing Protractor tests, but would also help maintaining good and reliable element locators.
The plugin would be of the most help if configured to run in your IDE of choice on the fly.
This gif shows integration of ESLint with eslint-plugin-protractor into WebStorm IDE. Find out more at WebStorm ESLint configuration.
Install ESLint and this plugin either locally or globally.
$ npm install eslint --save-dev
$ npm install eslint-plugin-protractor --save-dev
Install eslint-plugin-protractor
as a dev-dependency:
npm install --save-dev eslint-plugin-protractor
Enable the plugin by adding it to your .eslintrc
:
plugins:
- protractor
There are various types of rules implemented in the plugin. Here is a rough categorization.
browser.actions()
usageelement
and element.all
ElementArrayFinder
methods on ElementFinder
return
statements in callbacks of ElementArrayFinder
methodsgetInnerHtml()
and getOuterHtml()
methodsgetRawId()
methodgetLocationAbsUrl()
methodif
conditionElementFinder
or ElementArrayFinder
is declared with no applied actionexecuteScript()
or executeAsyncScript()
are called with missing or empty scriptelement()
, element.all()
, $()
and $$()
by.className()
locatorng-repeat
syntax in by.repeater()
locatorsby.id()
locatorby.tagName()
locatorbrowser.wait()
by.xpath()
locatorbrowser.get()
or browser.driver.get()
inside it()
browser.get()
or browser.driver.get()
first()
instead of get(0)
and last()
instead of get(-1)
count()
instead of then()
and length
protractor.promise.all()
to resolve multiple promises$
and $$
shortcutsbrowser.pause()
browser.sleep()
browser.driver
instead of browser
directlyHere is a table with all the available rules sorted by the default error level:
Rule | Default Error Level | Auto-fixable | Options |
---|---|---|---|
missing-perform | 2 (Error) | ||
no-browser-pause | 2 | ||
correct-chaining | 2 | Yes | |
no-invalid-selectors | 2 | ||
no-array-finder-methods | 2 | ||
valid-locator-type | 2 | ||
no-compound-classes | 2 | ||
no-get-inner-outer-html | 2 | ||
no-get-raw-id | 2 | ||
missing-wait-message | 1 (Warning) | ||
no-browser-sleep | 1 | ||
no-by-xpath | 1 | ||
no-describe-selectors | 1 | ||
no-angular-classes | 1 | ||
use-angular-locators | 1 | ||
no-angular-attributes | 1 | ||
no-bootstrap-classes | 1 | ||
use-simple-repeaters | 1 | ||
no-shadowing | 1 | ||
use-first-last | 1 | Yes | |
no-get-in-it | 1 | ||
array-callback-return | 1 | ||
no-absolute-url | 1 | ||
no-get-location-abs-url | 1 | ||
no-expect-in-po | 1 | requires plugin "settings" | |
no-promise-in-if | 1 | ||
no-execute-script | 1 | requires plugin "settings" | |
no-repetitive-locators | 1 | ||
no-repetitive-selectors | 1 | ||
use-count-method | 1 | ||
valid-by-id | 1 | ||
valid-by-tagname | 1 | ||
limit-selector-depth | 1 | number of nodes (default 5) | |
bare-element-finders | 1 | ||
empty-script | 1 | ||
use-promise-all | 0 (Turned off) | ||
by-css-shortcut | 0 | ||
no-browser-driver | 0 |
For example, the missing-perform
rule is enabled by default and will cause
ESLint to throw an error (with an exit code of 1
) when triggered.
The requires plugin "settings"
note indicates that a rule needs the plugin to have configured settings in your ESLint config.
For example, no-execute-script
rule expects configured paths to either spec, or page object files, or both.
You may customise each rule by adding a value in your .eslintrc
rules
property:
plugins:
- protractor
rules:
protractor/missing-perform: 0
See configuring rules for more information.
This plugin export a recommended
configuration that enforce good practices.
To enable this configuration use the extends
property in your .eslintrc
config file:
{
"plugins": [
"protractor"
],
"extends": "plugin:protractor/recommended"
}
See ESLint documentation for more information about extending configuration files.
© 2016-infinity Alexander Afanasyev and contributors.
Licensed under the MIT license.