1-
21const sleep = ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) )
32
3+ const log = ( message ) => cy . task ( 'log' , message )
4+
45const authenticate = ( ) => {
56 const password = Cypress . env ( 'password' )
67 if ( password ) {
7- cy . task ( ' log' , `Authenticating with ${ password } ` )
8+ log ( `Authenticating with ${ password } ` )
89 cy . get ( 'input#password' ) . type ( password )
910 cy . get ( 'form' ) . submit ( )
1011 }
1112}
1213
1314const waitForApplication = async ( path = '/index' ) => {
14- cy . task ( ' log' , `Waiting for app to restart and load ${ path } page` )
15+ log ( `Waiting for app to restart and load ${ path } page` )
1516 cy . task ( 'waitUntilAppRestarts' )
1617 cy . visit ( path )
1718 cy . get ( '.govuk-header__logotype-text' )
1819 . should ( 'contains.text' , 'GOV.UK' )
1920}
2021
2122const copyFile = ( source , target ) => {
22- cy . task ( ' log' , `Copy ${ source } to ${ target } ` )
23+ log ( `Copy ${ source } to ${ target } ` )
2324 cy . task ( 'copyFile' , { source, target } )
2425}
2526
2627const deleteFile = ( filename ) => {
27- cy . task ( ' log' , `Delete ${ filename } ` )
28+ log ( `Delete ${ filename } ` )
2829 cy . task ( 'deleteFile' , { filename } )
2930}
3031
3132const createFile = ( filename , options ) => {
32- cy . task ( ' log' , `Create ${ filename } ` )
33+ log ( `Create ${ filename } ` )
3334 cy . task ( 'createFile' , { filename, ...options } )
3435}
3536
@@ -38,7 +39,7 @@ const replaceInFile = (filename, originalText, source, newText) => {
3839}
3940
4041function uninstallPlugin ( plugin ) {
41- cy . task ( ' log' , `Uninstalling ${ plugin } ` )
42+ log ( `Uninstalling ${ plugin } ` )
4243 cy . exec ( `cd ${ Cypress . env ( 'projectFolder' ) } && npm uninstall ${ plugin } ` )
4344 cy . task ( 'pluginUninstalled' , { plugin, timeout : 15000 } )
4445}
@@ -47,18 +48,19 @@ function installPlugin (plugin, version = '') {
4748 if ( version ) {
4849 version = '@' + version
4950 }
50- cy . task ( ' log' , `Installing ${ plugin } ${ version } ` )
51+ log ( `Installing ${ plugin } ${ version } ` )
5152 cy . exec ( `cd ${ Cypress . env ( 'projectFolder' ) } && npm install ${ plugin } ${ version } --save-exact ` )
5253 if ( plugin . startsWith ( 'file:' ) ) {
5354 plugin = plugin . substring ( plugin . lastIndexOf ( '/' ) + 1 )
5455 }
55- cy . task ( ' log' , `Waiting for ${ plugin } ${ version } to be installed` )
56+ log ( `Waiting for ${ plugin } ${ version } to be installed` )
5657 cy . task ( 'pluginInstalled' , { plugin, version, timeout : 15000 } )
5758}
5859
5960module . exports = {
6061 authenticate,
6162 sleep,
63+ log,
6264 waitForApplication,
6365 copyFile,
6466 deleteFile,
0 commit comments