mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(runner): do not override trace files in afterAll (#14529)
This commit is contained in:
parent
947e6f58db
commit
2bcdf68ef5
@ -393,8 +393,11 @@ export class WorkerRunner extends EventEmitter {
|
||||
|
||||
// Run "afterAll" hooks for suites that are not shared with the next test.
|
||||
const nextSuites = new Set(getSuites(nextTest));
|
||||
// In case of failure the worker will be stopped and we have to make sure that afterAll
|
||||
// hooks run before test fixtures teardown.
|
||||
const isFailure = testInfo.status !== 'skipped' && testInfo.status !== testInfo.expectedStatus;
|
||||
for (const suite of reversedSuites) {
|
||||
if (!nextSuites.has(suite)) {
|
||||
if (!nextSuites.has(suite) || isFailure) {
|
||||
const afterAllError = await this._runAfterAllHooksForSuite(suite, testInfo);
|
||||
firstAfterHooksError = firstAfterHooksError || afterAllError;
|
||||
}
|
||||
|
@ -211,6 +211,37 @@ test('should work in serial mode', async ({ runInlineTest }, testInfo) => {
|
||||
expect(fs.existsSync(testInfo.outputPath('test-results', 'a-serial-fails', 'trace.zip'))).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should not override trace file in afterAll', async ({ runInlineTest, server }, testInfo) => {
|
||||
const result = await runInlineTest({
|
||||
'playwright.config.ts': `
|
||||
module.exports = { use: { trace: 'retain-on-failure' } };
|
||||
`,
|
||||
'a.spec.ts': `
|
||||
const { test } = pwt;
|
||||
|
||||
test('test 1', async ({ page }) => {
|
||||
await page.goto('about:blank');
|
||||
throw 'oh no!';
|
||||
});
|
||||
|
||||
// Another test in the same file to affect after hooks order.
|
||||
test('test 2', async ({}) => {
|
||||
});
|
||||
|
||||
test.afterAll(async ({ request }) => {
|
||||
await request.get('${server.EMPTY_PAGE}');
|
||||
});
|
||||
`,
|
||||
}, { workers: 1 });
|
||||
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.failed).toBe(1);
|
||||
expect(fs.existsSync(testInfo.outputPath('test-results', 'a-test-1', 'trace.zip'))).toBeTruthy();
|
||||
expect(fs.existsSync(testInfo.outputPath('test-results', 'a-test-1', 'trace-1.zip'))).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
async function parseTrace(file: string): Promise<Map<string, Buffer>> {
|
||||
const zipFS = new ZipFileSystem(file);
|
||||
const resources = new Map<string, Buffer>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user