File tree Expand file tree Collapse file tree 4 files changed +71
-0
lines changed Expand file tree Collapse file tree 4 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -79,3 +79,22 @@ The rule accepts a non-required option which can be used to specify custom match
79
79
]
80
80
}
81
81
```
82
+ ### ` no-page-pause `
83
+
84
+ Prevent usage of ` page.pause() ` .
85
+
86
+ #### Example
87
+
88
+ Example of ** incorrect** code for this rule:
89
+
90
+ ``` js
91
+ await page .click (' button' );
92
+ await page .pause ();
93
+ ```
94
+
95
+ Example of ** correct** code for this rule:
96
+
97
+ ``` js
98
+ await page .click (' button' );
99
+ ```
100
+
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ module.exports = {
10
10
rules : {
11
11
"no-empty-pattern" : "off" ,
12
12
"playwright/missing-playwright-await" : "error" ,
13
+ "playwright/no-page-pause" : "warn" ,
13
14
} ,
14
15
} ,
15
16
"jest-playwright" : {
@@ -20,6 +21,7 @@ module.exports = {
20
21
} ,
21
22
rules : {
22
23
"playwright/missing-playwright-await" : "error" ,
24
+ "playwright/no-page-pause" : "warn" ,
23
25
"jest/no-standalone-expect" : [
24
26
"error" ,
25
27
{
@@ -46,5 +48,6 @@ module.exports = {
46
48
} ,
47
49
rules : {
48
50
"missing-playwright-await" : missingPlaywrightAwait ,
51
+ "no-page-pause" : noPagePause ,
49
52
} ,
50
53
} ;
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ create ( context ) {
3
+ return {
4
+ MemberExpression ( node ) {
5
+ if ( node . object . name === "page" && node . property . name === "pause" ) {
6
+ context . report ( { messageId : "noPagePause" , node } ) ;
7
+ }
8
+ } ,
9
+ } ;
10
+ } ,
11
+ meta : {
12
+ docs : {
13
+ category : "Possible Errors" ,
14
+ description : "Prevent usage of page.pause()" ,
15
+ recommended : true ,
16
+ } ,
17
+ messages : {
18
+ noPagePause : "Unexpected use of page.pause()." ,
19
+ } ,
20
+ type : "problem" ,
21
+ } ,
22
+ } ;
Original file line number Diff line number Diff line change
1
+ const { RuleTester } = require ( "eslint" ) ;
2
+ const rule = require ( "../lib/rules/no-page-pause" ) ;
3
+
4
+ RuleTester . setDefaultConfig ( {
5
+ parserOptions : {
6
+ ecmaVersion : 2018 ,
7
+ } ,
8
+ } ) ;
9
+
10
+ const wrapInTest = ( input ) => `test('a', async () => { ${ input } })` ;
11
+
12
+ const invalid = ( code ) => ( {
13
+ code : wrapInTest ( code ) ,
14
+ errors : [ { messageId : "noPagePause" } ] ,
15
+ } ) ;
16
+
17
+ const valid = ( code ) => ( {
18
+ code : wrapInTest ( code ) ,
19
+ } ) ;
20
+
21
+ new RuleTester ( ) . run ( "no-page-pause" , rule , {
22
+ invalid : [ invalid ( "await page.pause()" ) ] ,
23
+ valid : [
24
+ valid ( "await page.click()" ) ,
25
+ valid ( "await expect(page).toBePaused()" ) ,
26
+ ] ,
27
+ } ) ;
You can’t perform that action at this time.
0 commit comments