From 95724dd8aff7dbefc3d171e3427e5313e7e6326f Mon Sep 17 00:00:00 2001 From: Junyi Du Date: Fri, 13 Jan 2023 02:01:24 +0800 Subject: [PATCH] test(e2e): fix trace file dump --- e2e-tests/fixtures.ts | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/e2e-tests/fixtures.ts b/e2e-tests/fixtures.ts index f09a33057..8b340e148 100644 --- a/e2e-tests/fixtures.ts +++ b/e2e-tests/fixtures.ts @@ -55,6 +55,7 @@ base.beforeAll(async () => { }) context = electronApp.context() await context.tracing.start({ screenshots: true, snapshots: true }); + await context.tracing.startChunk(); // NOTE: The following ensures App first start with the correct path. const info = await electronApp.evaluate(async ({ app }) => { @@ -133,14 +134,6 @@ base.beforeEach(async () => { } }) -base.afterAll(async () => { - // if (electronApp) { - // await electronApp.close() - //} - // use .dump as extension to avoid unfolded when zip by github - await context.tracing.stop({ path: `e2e-dump/trace-${Date.now()}.zip.dump` }); -}) - // hijack electron app into the test context // FIXME: add type to `block` export const test = base.extend({ @@ -283,3 +276,27 @@ export const test = base.extend({ await use(graphDir); }, }); + + +let getTracingFilePath = function(): string { + return `e2e-dump/trace-${Date.now()}.zip.dump` +} + + +test.afterAll(async () => { + await context.tracing.stopChunk({ path: getTracingFilePath() }); +}) + + +/** + * Trace all tests in a file + */ +export let traceAll = function(){ + test.beforeAll(async () => { + await context.tracing.startChunk(); + }) + + test.afterAll(async () => { + await context.tracing.stopChunk({ path: getTracingFilePath() }); + }) +}