@mmisty/eslint-plugin-cypress

0.0.5 • Public • Published

@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

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:

Option Description
pattern regexp
message string, error message
identifiers test 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",
},

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.5239latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.5239
0.0.40
0.0.30
0.0.20
0.0.10
0.0.1-alpha.00
0.0.00

Package Sidebar

Install

npm i @mmisty/eslint-plugin-cypress

Weekly Downloads

239

Version

0.0.5

License

Apache-2.0

Unpacked Size

11.4 kB

Total Files

7

Last publish

Collaborators

  • mmisty