Browse Source

spec: fix check for electron_common_testing binding in logging-spec.ts (#30104)

Co-authored-by: Milan Burda <[email protected]>
trop[bot] 3 years ago
parent
commit
c8cc2d86ad
1 changed files with 10 additions and 1 deletions
  1. 10 1
      spec-main/logging-spec.ts

+ 10 - 1
spec-main/logging-spec.ts

@@ -7,8 +7,17 @@ import * as fs from 'fs/promises';
 import * as path from 'path';
 import * as uuid from 'uuid';
 
+function isTestingBindingAvailable () {
+  try {
+    process._linkedBinding('electron_common_testing');
+    return true;
+  } catch {
+    return false;
+  }
+}
+
 // This test depends on functions that are only available when DCHECK_IS_ON.
-ifdescribe(process._linkedBinding('electron_common_testing'))('logging', () => {
+ifdescribe(isTestingBindingAvailable())('logging', () => {
   it('does not log by default', async () => {
     // ELECTRON_ENABLE_LOGGING is turned on in the appveyor config.
     const { ELECTRON_ENABLE_LOGGING: _, ...envWithoutEnableLogging } = process.env;