/
plugin-cypress.js
44 lines (36 loc) · 1.33 KB
/
plugin-cypress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict'
/**
* Plugin rules for writing effective Cypress tests
*
* 📝 https://github.com/cypress-io/eslint-plugin-cypress
*/
module.exports = {
// Require an assertion before a screenshot to help ensure consistent screenshots
'cypress/assertion-before-screenshot': 'error',
// Use closures to access the async values returned by Commands
'cypress/no-assigning-return-values': 'error',
// Disallow using force:true with action commands
'cypress/no-force': 'error',
// Use route aliases or assertions instead of `cy.wait` calls
'cypress/no-unnecessary-waiting': 'error',
// Require that Cypress interactions use data-selectors, eg data-testid, to
// help encourage test resiliency
'cypress/require-data-selectors': 'error',
// --- ⬆️ Rule overrides ---
// Allow using `function () {}` instead of arrow funcs to support accessing
// `this` inside of tests, where an arrow function will bind `this` to the
// incorrect scope:
//
// beforeEach(function () {
// cy.get('button').invoke('text').as('text')
// })
//
// it('has access to text', function () {
// this.text
// })
// TODO: verify that arrow funcs do indeed break this
'func-names': 'off',
// Allow triple slash type directives in order to include TypeScript
// <reference types="Cypress" /> directives
'spaced-comment': 'off',
}