feat(test runner): save traces for beforeAll/afterAll hooks (#10950)
This commit is contained in:
parent
230e0b7049
commit
192071d5bc
|
|
@ -262,9 +262,8 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
|||
|
||||
// 3. Determine whether we need the artifacts.
|
||||
const testFailed = testInfo.status !== testInfo.expectedStatus;
|
||||
const isHook = !!hookType(testInfo);
|
||||
const preserveTrace = captureTrace && !isHook && (traceMode === 'on' || (testFailed && traceMode === 'retain-on-failure') || (traceMode === 'on-first-retry' && testInfo.retry === 1));
|
||||
const captureScreenshots = !isHook && (screenshot === 'on' || (screenshot === 'only-on-failure' && testFailed));
|
||||
const preserveTrace = captureTrace && (traceMode === 'on' || (testFailed && traceMode === 'retain-on-failure') || (traceMode === 'on-first-retry' && testInfo.retry === 1));
|
||||
const captureScreenshots = (screenshot === 'on' || (screenshot === 'only-on-failure' && testFailed));
|
||||
|
||||
const traceAttachments: string[] = [];
|
||||
const addTraceAttachment = () => {
|
||||
|
|
|
|||
|
|
@ -145,6 +145,10 @@ test('should work with screenshot: on', async ({ runInlineTest }, testInfo) => {
|
|||
' test-failed-1.png',
|
||||
'artifacts-persistent-passing',
|
||||
' test-finished-1.png',
|
||||
'artifacts-shared-afterAll-worker0',
|
||||
' test-finished-1.png',
|
||||
'artifacts-shared-beforeAll-worker0',
|
||||
' test-finished-1.png',
|
||||
'artifacts-shared-shared-failing',
|
||||
' test-failed-1.png',
|
||||
'artifacts-shared-shared-passing',
|
||||
|
|
@ -210,6 +214,10 @@ test('should work with trace: on', async ({ runInlineTest }, testInfo) => {
|
|||
' trace.zip',
|
||||
'artifacts-persistent-passing',
|
||||
' trace.zip',
|
||||
'artifacts-shared-afterAll-worker0',
|
||||
' trace.zip',
|
||||
'artifacts-shared-beforeAll-worker0',
|
||||
' trace.zip',
|
||||
'artifacts-shared-shared-failing',
|
||||
' trace.zip',
|
||||
'artifacts-shared-shared-passing',
|
||||
|
|
@ -269,6 +277,8 @@ test('should work with trace: on-first-retry', async ({ runInlineTest }, testInf
|
|||
' trace.zip',
|
||||
'artifacts-persistent-failing-retry1',
|
||||
' trace.zip',
|
||||
'artifacts-shared-beforeAll-worker1-retry1',
|
||||
' trace.zip',
|
||||
'artifacts-shared-shared-failing-retry1',
|
||||
' trace.zip',
|
||||
'artifacts-two-contexts-failing-retry1',
|
||||
|
|
|
|||
|
|
@ -299,9 +299,12 @@ test('should render beforeAll/afterAll hooks', async ({ runInlineTest, page, sho
|
|||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = pwt;
|
||||
test.use({ trace: 'on' });
|
||||
test.beforeAll(async () => {
|
||||
});
|
||||
test.afterAll(async () => {
|
||||
test.afterAll(async ({ browser }) => {
|
||||
const page = await browser.newPage();
|
||||
await page.close();
|
||||
await test.step('after step', () => {
|
||||
throw new Error('oh!');
|
||||
});
|
||||
|
|
@ -328,6 +331,7 @@ test('should render beforeAll/afterAll hooks', async ({ runInlineTest, page, sho
|
|||
|
||||
await page.click('text=afterAll');
|
||||
await expect(page.locator('.tree-item:has-text("after step") svg.color-text-danger')).toHaveCount(1);
|
||||
await expect(page.locator('img')).toBeVisible();
|
||||
});
|
||||
|
||||
test('should render text attachments as text', async ({ runInlineTest, page, showReport }) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue