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:
Thomas Roberts 2022-02-24 09:06:24 +00:00 committed by GitHub
parent 2a5a40279f
commit 918de7bc75
1 changed files with 13 additions and 3 deletions

View File

@ -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',
} );
} }
} }
} }