eslint-plugin-cypress 3.0.3 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,11 +9,11 @@ Examples of **incorrect** code for this rule:
9
9
 
10
10
  ```js
11
11
  cy.pause();
12
+ cy.get('selector').pause();
12
13
  ```
13
14
 
14
15
  Examples of **correct** code for this rule:
15
16
 
16
17
  ```js
17
- // only the parent cy.pause command is detected
18
- cy.get('selector').pause();
18
+ cy.get('selector')
19
19
  ```
@@ -35,12 +35,15 @@ module.exports = {
35
35
  }
36
36
 
37
37
  function isCypressCall (node) {
38
- return node.callee &&
39
- node.callee.type === 'MemberExpression' &&
40
- node.callee.object.type === 'Identifier' &&
41
- node.callee.object.name === 'cy'
38
+ if (!node.callee || node.callee.type !== 'MemberExpression') {
39
+ return false;
40
+ }
41
+ if (node.callee.object.type === 'Identifier' && node.callee.object.name === 'cy') {
42
+ return true;
43
+ }
44
+ return isCypressCall(node.callee.object);
42
45
  }
43
-
46
+
44
47
  //----------------------------------------------------------------------
45
48
  // Public
46
49
  //----------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-cypress",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "An ESLint plugin for projects using Cypress",
5
5
  "main": "index.js",
6
6
  "author": "Cypress-io",
@@ -20,14 +20,18 @@ const ruleTester = new RuleTester()
20
20
  ruleTester.run('no-pause', rule, {
21
21
 
22
22
  valid: [
23
- // for now, we do not detect .pause() child command
24
- { code: `cy.get('button').pause()`, parserOptions },
25
23
  { code: `pause()`, parserOptions },
26
24
  { code: `cy.get('button').dblclick()`, parserOptions },
27
25
  ],
28
-
26
+
29
27
  invalid: [
30
28
  { code: `cy.pause()`, parserOptions, errors },
31
29
  { code: `cy.pause({ log: false })`, parserOptions, errors },
30
+ { code: `cy.get('button').pause()`, parserOptions, errors },
31
+ {
32
+ code: `cy.get('a').should('have.attr', 'href').and('match', /dashboard/).pause()`,
33
+ parserOptions,
34
+ errors
35
+ }
32
36
  ],
33
37
  })