File tree 6 files changed +78
-2
lines changed
6 files changed +78
-2
lines changed Original file line number Diff line number Diff line change
1
+ 0.8.0
2
+
3
+ * Added ` setCommonPlugins ` hook
4
+
1
5
0.7.0
2
6
3
7
* Added ` setTestHost ` hook
7
11
8
12
* Added ` setBrowser ` hook
9
13
* Added try/catch block when taking cookie for ` setSharedCookie `
10
- * CodeceptJS 3 compatibility
14
+ * CodeceptJS 3 compatibility
Original file line number Diff line number Diff line change @@ -61,6 +61,26 @@ const { setHeadlessWhen } = require('@codeceptjs/configure');
61
61
// export DEV=true && npx codeceptjs run
62
62
setHeadedWhen (process .env .DEV );
63
63
```
64
+ ### setCommonPlugins
65
+
66
+ Enables CodeceptJS plugins which are recommened for common usage.
67
+ The list of plugins can be updated from version to version so this hook ensures that all of them are loaded and you won't need to update them in a config:
68
+
69
+ ``` js
70
+ // in codecept.conf.js
71
+ const { setHeadlessWhen } = require (' @codeceptjs/configure' );
72
+
73
+ setCommonPlugins ();
74
+ ```
75
+
76
+ These plugins will be loaded:
77
+
78
+ * tryTo
79
+ * retryFailedStep
80
+ * retryTo
81
+ * eachElement
82
+ * pauseOnFail
83
+ * screenshotOnFail
64
84
65
85
### setSharedCookies
66
86
Original file line number Diff line number Diff line change
1
+ const { config } = require ( '../codeceptjs' ) ;
2
+
3
+ module . exports = function ( ) {
4
+
5
+ config . addHook ( cfg => {
6
+ if ( ! cfg . plugins ) cfg . plugins = { } ;
7
+ cfg . plugins . tryTo = cfg . plugins . tryTo || { enabled : true } ;
8
+ cfg . plugins . retryFailedStep = cfg . plugins . retryFailedStep || { enabled : false } ;
9
+ cfg . plugins . retryTo = cfg . plugins . retryTo || { enabled : true } ;
10
+ cfg . plugins . eachElement = cfg . plugins . eachElement || { enabled : true } ;
11
+ cfg . plugins . pauseOnFail = cfg . plugins . pauseOnFail || { } ;
12
+ cfg . plugins . screenshotOnFail = cfg . plugins . screenshotOnFail || { } ;
13
+ } ) ;
14
+ }
Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ module.exports = {
5
5
setWindowSize : require ( './hooks/setWindowSize' ) ,
6
6
setBrowser : require ( './hooks/setBrowser' ) ,
7
7
setTestHost : require ( './hooks/setTestHost' ) ,
8
+ setCommonPlugins : require ( './hooks/setCommonPlugins' ) ,
8
9
}
Original file line number Diff line number Diff line change 27
27
},
28
28
"devDependencies" : {
29
29
"chai" : " ^4.2.0" ,
30
- "codeceptjs" : " ^3.0 .0" ,
30
+ "codeceptjs" : " ^3.3 .0" ,
31
31
"mocha" : " ^8.2.1" ,
32
32
"puppeteer" : " ^2.1" ,
33
33
"webdriverio" : " ^6.4.2"
Original file line number Diff line number Diff line change 7
7
setWindowSize,
8
8
setBrowser,
9
9
setTestHost,
10
+ setCommonPlugins,
10
11
} = require ( '../index' ) ;
11
12
12
13
describe ( 'Hooks tests' , ( ) => {
@@ -308,4 +309,40 @@ describe('Hooks tests', () => {
308
309
} ) ;
309
310
} ) ;
310
311
} ) ;
312
+
313
+ describe ( '#setCommonPlugins' , ( ) => {
314
+ it ( 'create standard plugins' , ( ) => {
315
+ Config . reset ( ) ;
316
+ const config = {
317
+ helpers : { } ,
318
+ }
319
+ setCommonPlugins ( ) ;
320
+ Config . create ( config ) ;
321
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.screenshotOnFail` ) ;
322
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.tryTo` ) ;
323
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.retryTo` ) ;
324
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.eachElement` ) ;
325
+ } ) ;
326
+
327
+ it ( 'should not override plugins' , ( ) => {
328
+ Config . reset ( ) ;
329
+ const config = {
330
+ helpers : { } ,
331
+ plugins : {
332
+ screenshotOnFail : { enabled : false } ,
333
+ otherPlugin : { }
334
+ }
335
+ }
336
+ setCommonPlugins ( ) ;
337
+ Config . create ( config ) ;
338
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.screenshotOnFail` ) ;
339
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.screenshotOnFail.enabled` ) ;
340
+ expect ( Config . get ( ) . plugins . screenshotOnFail . enabled ) . to . be . false ;
341
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.tryTo` ) ;
342
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.retryTo` ) ;
343
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.eachElement` ) ;
344
+ expect ( Config . get ( ) ) . to . have . nested . property ( `plugins.otherPlugin` ) ;
345
+ } ) ;
346
+ } ) ;
347
+
311
348
} ) ;
You can’t perform that action at this time.
0 commit comments