Ensure screenshots can be attached in jest html report (https://github.com/woocommerce/woocommerce-blocks/pull/5919)
* Ensure screenshots can be attached in jest html report * Force tests to fail in ci * Console log for testing * Console log for testing * Check on hook failure as well as test failure * Revert "Force tests to fail in ci" This reverts commit 6efebd63bba4792214f5b24824fb405cf38b1367. * Take full page screenshot only when error type is not hook_failure * Remove console log
This commit is contained in:
parent
2a5a40279f
commit
918de7bc75
|
@ -6,9 +6,19 @@ const { addAttach } = require( 'jest-html-reporters/helper' );
|
||||||
|
|
||||||
class E2EEnvironment extends PuppeteerEnvironment {
|
class E2EEnvironment extends PuppeteerEnvironment {
|
||||||
async handleTestEvent( event ) {
|
async handleTestEvent( event ) {
|
||||||
if ( event.name === 'test_fn_failure' ) {
|
if (
|
||||||
const data = await this.global.page.screenshot();
|
event.name === 'test_fn_failure' ||
|
||||||
await addAttach( data, 'Full Page Screenshot', this.global );
|
event.name === 'hook_failure'
|
||||||
|
) {
|
||||||
|
const attach = await this.global.page.screenshot( {
|
||||||
|
fullPage: event.name !== 'hook_failure',
|
||||||
|
} );
|
||||||
|
await addAttach( {
|
||||||
|
attach,
|
||||||
|
description: 'Full Page Screenshot',
|
||||||
|
context: this.global,
|
||||||
|
bufferFormat: 'png',
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue