File tree Expand file tree Collapse file tree 6 files changed +78
-2
lines changed
Expand file tree Collapse file tree 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+
150.7.0
26
37* Added ` setTestHost ` hook
711
812* Added ` setBrowser ` hook
913* 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');
6161// export DEV=true && npx codeceptjs run
6262setHeadedWhen (process .env .DEV );
6363```
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
6484
6585### setSharedCookies
6686
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 = {
55 setWindowSize : require ( './hooks/setWindowSize' ) ,
66 setBrowser : require ( './hooks/setBrowser' ) ,
77 setTestHost : require ( './hooks/setTestHost' ) ,
8+ setCommonPlugins : require ( './hooks/setCommonPlugins' ) ,
89}
Original file line number Diff line number Diff line change 2727 },
2828 "devDependencies" : {
2929 "chai" : " ^4.2.0" ,
30- "codeceptjs" : " ^3.0 .0" ,
30+ "codeceptjs" : " ^3.3 .0" ,
3131 "mocha" : " ^8.2.1" ,
3232 "puppeteer" : " ^2.1" ,
3333 "webdriverio" : " ^6.4.2"
Original file line number Diff line number Diff line change 77 setWindowSize,
88 setBrowser,
99 setTestHost,
10+ setCommonPlugins,
1011} = require ( '../index' ) ;
1112
1213describe ( 'Hooks tests' , ( ) => {
@@ -308,4 +309,40 @@ describe('Hooks tests', () => {
308309 } ) ;
309310 } ) ;
310311 } ) ;
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+
311348} ) ;
You can’t perform that action at this time.
0 commit comments