2021-10-08 10:58:44 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
const PuppeteerEnvironment = require( 'jest-environment-puppeteer' );
|
|
|
|
const { addAttach } = require( 'jest-html-reporters/helper' );
|
|
|
|
|
|
|
|
class E2EEnvironment extends PuppeteerEnvironment {
|
|
|
|
async handleTestEvent( event ) {
|
2022-02-24 09:06:24 +00:00
|
|
|
if (
|
|
|
|
event.name === 'test_fn_failure' ||
|
|
|
|
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',
|
|
|
|
} );
|
2021-10-08 10:58:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = E2EEnvironment;
|