Browse Source

Backport PR jupyterlab#11575: Fix markdown benchmark snapshot (#11577)

Co-authored-by: Frédéric Collonval <fcollonval@gmail.com>
MeeseeksMachine 3 years ago
parent
commit
ca9c16971a

+ 2 - 0
.github/workflows/galata.yml

@@ -72,6 +72,8 @@ jobs:
         run: |
           cd galata
           jlpm run test
+          # Run once benchmark tests to ensure they have no regression
+          BENCHMARK_NUMBER_SAMPLES=1 jlpm run test:benchmark
 
       - name: Upload Galata Test assets
         if: always()

+ 6 - 2
galata/src/benchmarkReporter.ts

@@ -510,6 +510,7 @@ class BenchmarkReporter implements Reporter {
   ): Promise<[string, string]> {
     // Compute statistics
     // - Groupby (test, browser, reference | project, file)
+    const reportExtension = 'md';
 
     const groups = new Map<
       string,
@@ -548,8 +549,12 @@ class BenchmarkReporter implements Reporter {
     });
 
     // If the reference | project lists has two items, the intervals will be compared.
+    if (!groups.values().next().value) {
+      return ['## Benchmark report\n\nNot enough data', reportExtension];
+    }
+
     const compare =
-      (groups.values().next().value.values().next().value as Map<
+      (groups.values().next().value?.values().next().value as Map<
         string,
         Map<string, number[]>
       >).size === 2;
@@ -658,7 +663,6 @@ class BenchmarkReporter implements Reporter {
       );
     }
     reportContent.push('', '</details>', '');
-    const reportExtension = 'md';
     const reportContentString = reportContent.join('\n');
     return [reportContentString, reportExtension];
   }

+ 1 - 1
galata/test/benchmark/notebook.spec.ts

@@ -98,7 +98,7 @@ test.describe('Benchmark', () => {
         file: path.basename(file, '.ipynb'),
         project: testInfo.project.name
       };
-      const perf = new galata.newPerformanceHelper(page);
+      const perf = galata.newPerformanceHelper(page);
 
       await page.goto(baseURL + '?reset');