An ESLint plugin for projects that use Cypress
Switch branches/tags
Nothing to show
Clone or download

README.md

Cypress ESLint Plugin

An ESLint plugin for your Cypress tests.

Specifies globals for Cypress cy, Cypress, browser and mocha globals.

Installation

npm install eslint-plugin-cypress --save-dev

Usage

Add an .eslintrc.json file to your cypress directory with the following:

// my-project/cypress/.eslintrc.json

{
  "plugins": [
    "cypress"
  ],
  "env": {
    "cypress/globals": true
  }
}

Chai and no-unused-expressions

Using an assertion such as expect(value).to.be.true can fail the ESLint rule no-unused-expressions even though it's not an error in this case. To fix this, you can install and use eslint-plugin-chai-friendly.

npm install --save-dev eslint-plugin-chai-friendly

In your .eslintrc.json:

{
  "plugins": [
    "cypress",
    "chai-friendly"
  ],
  "rules": {
    "no-unused-expressions": 0,
    "chai-friendly/no-unused-expressions": 2
  }
}