test: add screenshot capture on test failure in E2E tests
This commit is contained in:
parent
f0c2e6e275
commit
8f3da4b859
@ -43,7 +43,27 @@ test.describe('Web Component E2E Tests', () => {
|
|||||||
await page.waitForSelector('#join-as-publisher');
|
await page.waitForSelector('#join-as-publisher');
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach(async () => {
|
test.afterEach(async ({}, testInfo) => {
|
||||||
|
if (testInfo.status !== testInfo.expectedStatus) {
|
||||||
|
console.log(`Test falló: ${testInfo.title}`);
|
||||||
|
|
||||||
|
// Take screenshot if the test fails
|
||||||
|
if (page && !page.isClosed()) {
|
||||||
|
try {
|
||||||
|
const screenshotBuffer = await page.screenshot({
|
||||||
|
fullPage: true,
|
||||||
|
type: 'png',
|
||||||
|
});
|
||||||
|
|
||||||
|
const screenshotBase64 = screenshotBuffer.toString('base64');
|
||||||
|
|
||||||
|
console.log('Screenshot en base64:');
|
||||||
|
console.log(`data:image/png;base64,${screenshotBase64}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error al capturar screenshot:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
await context.storageState({ path: 'test_localstorage_state.json' });
|
await context.storageState({ path: 'test_localstorage_state.json' });
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user