Merge branch 'stevanfreeborn/feat-29531/retain-first-failure-only' of https://github.com/StevanFreeborn/playwright into stevanfreeborn/feat-29531/retain-first-failure-only
This commit is contained in:
commit
bd021abf4e
|
|
@ -401,6 +401,7 @@ test('should respect PW_TEST_DISABLE_TRACING', async ({ runInlineTest }, testInf
|
||||||
expect(fs.existsSync(testInfo.outputPath('test-results', 'a-test-1', 'trace.zip'))).toBe(false);
|
expect(fs.existsSync(testInfo.outputPath('test-results', 'a-test-1', 'trace.zip'))).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (const mode of ['off', 'retain-on-failure', 'on-first-retry', 'on-all-retries', 'on-first-failure']) {
|
||||||
for (const mode of ['off', 'retain-on-failure', 'on-first-retry', 'on-all-retries', 'on-first-failure']) {
|
for (const mode of ['off', 'retain-on-failure', 'on-first-retry', 'on-all-retries', 'on-first-failure']) {
|
||||||
test(`trace:${mode} should not create trace zip artifact if page test passed`, async ({ runInlineTest }) => {
|
test(`trace:${mode} should not create trace zip artifact if page test passed`, async ({ runInlineTest }) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
|
|
@ -1034,6 +1035,68 @@ test('should attribute worker fixture teardown to the right test', async ({ runI
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('trace:on-first-failure should create trace if context is closed before failure in the test', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = { use: { trace: 'on-first-failure' } };
|
||||||
|
`,
|
||||||
|
'a.spec.ts': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('passing test', async ({ page, context }) => {
|
||||||
|
await page.goto('about:blank');
|
||||||
|
await context.close();
|
||||||
|
expect(1).toBe(2);
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { trace: 'retain-on-failure' });
|
||||||
|
const tracePath = test.info().outputPath('test-results', 'a-passing-test', 'trace.zip');
|
||||||
|
const trace = await parseTrace(tracePath);
|
||||||
|
expect(trace.apiNames).toContain('page.goto');
|
||||||
|
expect(result.failed).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('trace:on-first-failure should create trace if context is closed before failure in afterEach', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = { use: { trace: 'on-first-failure' } };
|
||||||
|
`,
|
||||||
|
'a.spec.ts': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('passing test', async ({ page, context }) => {
|
||||||
|
});
|
||||||
|
test.afterEach(async ({ page, context }) => {
|
||||||
|
await page.goto('about:blank');
|
||||||
|
await context.close();
|
||||||
|
expect(1).toBe(2);
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { trace: 'retain-on-failure' });
|
||||||
|
const tracePath = test.info().outputPath('test-results', 'a-passing-test', 'trace.zip');
|
||||||
|
const trace = await parseTrace(tracePath);
|
||||||
|
expect(trace.apiNames).toContain('page.goto');
|
||||||
|
expect(result.failed).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('trace:on-first-failure should create trace if request context is disposed before failure', async ({ runInlineTest, server }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = { use: { trace: 'on-first-failure' } };
|
||||||
|
`,
|
||||||
|
'a.spec.ts': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
test('passing test', async ({ request }) => {
|
||||||
|
expect(await request.get('${server.EMPTY_PAGE}')).toBeOK();
|
||||||
|
await request.dispose();
|
||||||
|
expect(1).toBe(2);
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { trace: 'retain-on-failure' });
|
||||||
|
const tracePath = test.info().outputPath('test-results', 'a-passing-test', 'trace.zip');
|
||||||
|
const trace = await parseTrace(tracePath);
|
||||||
|
expect(trace.apiNames).toContain('apiRequestContext.get');
|
||||||
|
expect(result.failed).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
test('trace:on-first-failure should create trace but only on first failure', async ({ runInlineTest }) => {
|
test('trace:on-first-failure should create trace but only on first failure', async ({ runInlineTest }) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
'a.spec.ts': `
|
'a.spec.ts': `
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue