Browse Source

test(e2e): fix trace file dump

Junyi Du 2 years ago
parent
commit
95724dd8af
1 changed files with 25 additions and 8 deletions
  1. 25 8
      e2e-tests/fixtures.ts

+ 25 - 8
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<LogseqFixtures>({
@@ -283,3 +276,27 @@ export const test = base.extend<LogseqFixtures>({
     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() });
+  })
+}