test: support for adding extra module paths (#26490)
This commit is contained in:
parent
023c89265f
commit
2b4ce387bc
2 changed files with 15 additions and 0 deletions
|
@ -4,6 +4,13 @@ const v8 = require('v8');
|
||||||
|
|
||||||
Module.globalPaths.push(path.resolve(__dirname, '../spec/node_modules'));
|
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
|
// We want to terminate on errors, not throw up a dialog
|
||||||
process.on('uncaughtException', (err) => {
|
process.on('uncaughtException', (err) => {
|
||||||
console.error('Unhandled exception in main spec runner:', err);
|
console.error('Unhandled exception in main spec runner:', err);
|
||||||
|
|
|
@ -5,10 +5,18 @@
|
||||||
// Deprecated APIs are still supported and should be tested.
|
// Deprecated APIs are still supported and should be tested.
|
||||||
process.throwDeprecation = false
|
process.throwDeprecation = false
|
||||||
|
|
||||||
|
const Module = require('module');
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const { ipcRenderer } = 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
|
// Set up chai-as-promised here first to avoid conflicts
|
||||||
// It must be loaded first or really strange things happen inside
|
// It must be loaded first or really strange things happen inside
|
||||||
// chai that cause test failures
|
// chai that cause test failures
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue