File tree 4 files changed +8
-13
lines changed
4 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ These rules enforce some of the [best practices recommended for using Cypress](h
54
54
| [ no-force] ( docs/rules/no-force.md ) | disallow using ` force: true ` with action commands | |
55
55
| [ no-pause] ( docs/rules/no-pause.md ) | disallow using ` cy.pause() ` calls | |
56
56
| [ no-unnecessary-waiting] ( docs/rules/no-unnecessary-waiting.md ) | disallow waiting for arbitrary time periods | ✅ |
57
- | [ no-xpath] ( docs/rules/no-xpath.md ) | disallow usage of xpath in selector | |
57
+ | [ no-xpath] ( docs/rules/no-xpath.md ) | disallow using ` cy. xpath() ` calls | |
58
58
| [ require-data-selectors] ( docs/rules/require-data-selectors.md ) | require ` data-* ` attribute selectors | |
59
59
| [ unsafe-to-chain-command] ( docs/rules/unsafe-to-chain-command.md ) | disallow actions within chains | ✅ |
60
60
Original file line number Diff line number Diff line change 2
2
3
3
<!-- end auto-generated rule header -->
4
4
5
- This rule disallow the usage of cypress- xpath for selecting elements.
5
+ This rule disallows the usage of ` cy. xpath() ` for selecting elements.
6
6
7
+ ## Rule Details
7
8
8
9
Examples of ** incorrect** code for this rule:
9
10
10
11
``` js
11
-
12
12
cy .xpath (' //div[@class=\" container\" ]' ).click ()
13
13
```
14
14
15
15
Examples of ** correct** code for this rule:
16
16
17
-
18
17
``` js
19
-
20
18
cy .get (' [data-cy="container"]' ).click ();
21
19
```
22
20
23
-
24
21
## Further Reading
25
22
26
- Both ` @cypress/xpath ` and ` cypress-xpath ` packages have been deprecated since Oct 13, 2022.
27
-
23
+ Both ` @cypress/xpath ` and ` cypress-xpath ` are deprecated.
28
24
29
25
See [ the Cypress Best Practices guide] ( https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements ) .
Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ module.exports = {
4
4
meta : {
5
5
type : 'suggestion' ,
6
6
docs : {
7
- description : " disallow using cy.xpath() calls" ,
7
+ description : ' disallow using ` cy.xpath()` calls' ,
8
8
recommended : false ,
9
- url : " https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-xpath.md"
9
+ url : ' https://github.com/cypress-io/eslint-plugin-cypress/blob/master/docs/rules/no-xpath.md'
10
10
} ,
11
11
fixable : null , // Or `code` or `whitespace`
12
12
schema : [ ] , // Add a schema if the rule has options
13
13
messages : {
14
- unexpected : 'avoid using cypress xpath' ,
15
- } ,
14
+ unexpected : 'Avoid using cy. xpath command ' ,
15
+ } ,
16
16
} ,
17
17
18
18
create ( context ) {
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ const rule = require("../../../lib/rules/no-xpath"),
14
14
const ruleTester = new RuleTester ( ) ;
15
15
ruleTester . run ( "no-xpath" , rule , {
16
16
valid : [
17
- { code : 'cy.wait("@someRequest")' } ,
18
17
{ code : 'cy.get("button").click({force: true})' } ,
19
18
] ,
20
19
You can’t perform that action at this time.
0 commit comments