0.0.5 • Published 7 months ago

@mmisty/eslint-plugin-cypress v0.0.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

@mmisty/eslint-plugin-cypress

Additional linter rules for cypress tests

Table of Contents

  1. Installation
  2. Recommended settings
  3. Setup
  4. Rules

Installation

yarn add -D @mmisty/eslint-plugin-cypress
npm i --save-dev @mmisty/eslint-plugin-cypress

Recommended settings

You can use recommended settings for cypress or jest.

Just add the following into .eslintrc.js

// .eslintrc.js
extends: ['plugin:@mmisty/cypress/recommended'],

Setup

To enable rules add the following to plugins section in your .eslintrc.js:

plugins: ['@mmisty/cypress'],

and add rules you want:

rules: {
  "@mmisty/cypress/test-title-pattern": 'error'
}

Rules

disallow-get-get-chain

Disallows chaining specified commands (default ['get']).

Will warn when user tries to do chains like cy.get('id').get('id2');

rules: {
  '@mmisty/cypress/disallow-get-get-chain': ['error', { methods: ['qaId', 'get'] }],
}

test-title-pattern

The rule will check whether test has title matched with pattern - default pattern not allows '.' at the end of test title

Available options:

OptionDescription
patternregexp
messagestring, error message
identifierstest identifiers. ex it/xit

To configure the rule with options:

rules: {
  "@mmisty/cypress/test-title-pattern": ["error", {
     pattern: /^ID\d+\w+should/i,
     message: "Test should have ID",
     identifiers: ['it']
  }],
},

disallow-only

Disallows .only in tests To configure the rule:

rules: {
  "@mmisty/cypress/disallow-only": "error",
},
0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago

0.0.1-alpha.0

7 months ago

0.0.0

7 months ago