diff --git a/package.json b/package.json index 3a66534c86..b74b636334 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "engines": { "node": ">=14" }, + "atomTestRunner": "runners/jasmine2-test-runner", "license": "MIT", "electronVersion": "12.2.3", "resolutions": { diff --git a/src/main-process/atom-application.js b/src/main-process/atom-application.js index fca09ac1f6..1b34620ce1 100644 --- a/src/main-process/atom-application.js +++ b/src/main-process/atom-application.js @@ -1747,39 +1747,65 @@ module.exports = class AtomApplication extends EventEmitter { } resolveTestRunnerPath(testPath) { - let packageRoot; - if (FindParentDir == null) { - FindParentDir = require('find-parent-dir'); + FindParentDir ||= require('find-parent-dir'); + + let packageRoot = FindParentDir.sync(testPath, 'package.json'); + + if (!packageRoot) { + process.stderr.write('Error: Could not find root directory'); + process.exit(1); } - if ((packageRoot = FindParentDir.sync(testPath, 'package.json'))) { - const packageMetadata = require(path.join(packageRoot, 'package.json')); - if (packageMetadata.atomTestRunner) { - let testRunnerPath; - if (Resolve == null) { - Resolve = require('resolve'); - } - if ( - (testRunnerPath = Resolve.sync(packageMetadata.atomTestRunner, { - basedir: packageRoot, - extensions: Object.keys(require.extensions) - })) - ) { - return testRunnerPath; - } else { - process.stderr.write( - `Error: Could not resolve test runner path '${ - packageMetadata.atomTestRunner - }'` - ); - process.exit(1); - } + const packageMetadata = require(path.join(packageRoot, 'package.json')); + let atomTestRunner = packageMetadata.atomTestRunner; + + if (!atomTestRunner) { + process.stdout.write('atomTestRunner was not defined, using the deprecated runners/jasmine1-test-runner.'); + atomTestRunner = 'runners/jasmine1-test-runner'; + } + + let testRunnerPath; + Resolve ||= require('resolve'); + + // First try to run with local runners (e.g: `./test/runner.js`) or packages (e.g.: `atom-mocha-test-runner`) + try { + testRunnerPath = Resolve.sync(atomTestRunner, { + basedir: packageRoot, + extensions: Object.keys(require.extensions) + }); + + if (testRunnerPath) { + return testRunnerPath; } + } catch { + // Nothing to do, try the next strategy } - return this.resolveLegacyTestRunnerPath(); + // Then try to use one of the runners defined in Pulsar + try { + testRunnerPath = Resolve.sync(`./spec/${atomTestRunner}`, { + basedir: this.devResourcePath, + extensions: Object.keys(require.extensions) + }); + + if (testRunnerPath) { + return testRunnerPath; + } + } catch { + // Nothing to do, try the next strategy + } + + // TODO: packages might require __dirname ? + + process.stderr.write( + `Error: Could not resolve test runner path '${ + packageMetadata.atomTestRunner + }'` + ); + process.exit(1); } + // TODO: remove? resolveLegacyTestRunnerPath() { try { return require.resolve( diff --git a/src/main-process/atom-window.js b/src/main-process/atom-window.js index 4343124b6b..2aabd7b6b3 100644 --- a/src/main-process/atom-window.js +++ b/src/main-process/atom-window.js @@ -60,7 +60,6 @@ module.exports = class AtomWindow extends EventEmitter { disableBlinkFeatures: 'Auxclick', nodeIntegration: true, contextIsolation: false, - enableRemoteModule: true, webviewTag: true, // TodoElectronIssue: remote module is deprecated https://www.electronjs.org/docs/breaking-changes#default-changed-enableremotemodule-defaults-to-false