Browse Source

test: add disabled tests list (#37334)

Calvin 2 years ago
parent
commit
1f390119fe
2 changed files with 16 additions and 0 deletions
  1. 3 0
      spec/disabled-tests.json
  2. 13 0
      spec/index.js

+ 3 - 0
spec/disabled-tests.json

@@ -0,0 +1,3 @@
+[
+  "// NOTE: this file is used to disable tests in our test suite by their full title."
+]

+ 13 - 0
spec/index.js

@@ -1,3 +1,4 @@
+const fs = require('fs');
 const path = require('path');
 const v8 = require('v8');
 
@@ -65,6 +66,18 @@ app.whenReady().then(async () => {
   }
   const mocha = new Mocha(mochaOptions);
 
+  // Add a root hook on mocha to skip any tests that are disabled
+  const disabledTests = new Set(
+    JSON.parse(
+      fs.readFileSync(path.join(__dirname, 'disabled-tests.json'), 'utf8')
+    )
+  );
+  mocha.suite.beforeEach(function () {
+    if (disabledTests.has(this.currentTest?.fullTitle())) {
+      this.skip();
+    }
+  });
+
   // The cleanup method is registered this way rather than through an
   // `afterEach` at the top level so that it can run before other `afterEach`
   // methods.