include the current block in screenshot params

This commit is contained in:
Ron Rennick 2021-03-09 10:19:43 -04:00
parent 4c88973039
commit 2d8ab6e2f8
1 changed files with 7 additions and 7 deletions

View File

@ -61,14 +61,14 @@ global.describe = (() => {
*/ */
global.it = (() => { global.it = (() => {
const test = async ( testName, callback ) => { const test = async ( testName, callback ) => {
const testCallback = async () => screenshotTest( testName, callback ); const testCallback = async () => screenshotTest( currentBlock, testName, callback );
return originalIt( testName, testCallback ); return originalIt( testName, testCallback );
}; };
const only = ( blockName, callback ) => { const only = ( testName, callback ) => {
return originalIt.only( blockName, callback ); return originalIt.only( testName, callback );
}; };
const skip = ( blockName, callback ) => { const skip = ( testName, callback ) => {
return originalIt.skip( blockName, callback ); return originalIt.skip( testName, callback );
}; };
test.each = bind( test, false ); test.each = bind( test, false );
@ -86,11 +86,11 @@ global.it = (() => {
* @param callback * @param callback
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
const screenshotTest = async ( testName, callback ) => { const screenshotTest = async ( blockName, testName, callback ) => {
try { try {
await callback(); await callback();
} catch ( e ) { } catch ( e ) {
const testTitle = `${ currentBlock } - ${ testName }`.replace( /\.$/, '' ); const testTitle = `${ blockName } - ${ testName }`.replace( /\.$/, '' );
const appPath = getAppRoot(); const appPath = getAppRoot();
const savePath = path.resolve( appPath, 'tests/e2e/screenshots' ); const savePath = path.resolve( appPath, 'tests/e2e/screenshots' );
const filePath = path.join( const filePath = path.join(