Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: support for adding extra module paths #26543

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions spec-main/index.js
Expand Up @@ -4,6 +4,13 @@ const v8 = require('v8');

Module.globalPaths.push(path.resolve(__dirname, '../spec/node_modules'));

// Extra module paths which can be used to load Mocha reporters
if (process.env.ELECTRON_TEST_EXTRA_MODULE_PATHS) {
for (const modulePath of process.env.ELECTRON_TEST_EXTRA_MODULE_PATHS.split(':')) {
Module.globalPaths.push(modulePath);
}
}

// We want to terminate on errors, not throw up a dialog
process.on('uncaughtException', (err) => {
console.error('Unhandled exception in main spec runner:', err);
Expand Down
8 changes: 8 additions & 0 deletions spec/static/index.html
Expand Up @@ -5,10 +5,18 @@
// Deprecated APIs are still supported and should be tested.
process.throwDeprecation = false

const Module = require('module');
const path = require('path')
const electron = require('electron')
const { ipcRenderer } = electron

// Extra module paths which can be used to load Mocha reporters
if (process.env.ELECTRON_TEST_EXTRA_MODULE_PATHS) {
for (const modulePath of process.env.ELECTRON_TEST_EXTRA_MODULE_PATHS.split(':')) {
Module.globalPaths.push(modulePath);
}
}

// Set up chai-as-promised here first to avoid conflicts
// It must be loaded first or really strange things happen inside
// chai that cause test failures
Expand Down