see if this helps

This commit is contained in:
John Kleinschmidt
2024-11-25 16:02:20 -05:00
parent 864432cd4e
commit 9a15a69cf7

View File

@@ -108,9 +108,22 @@ app.whenReady().then(async () => {
// 3. regular `afterEach` hooks run.
// 4. `afterAll` hook runs here to verify that there are no windows left open
const { runCleanupFunctions } = require('./lib/spec-helpers');
mocha.suite.on('suite', function attach (suite) {
function attach (suite) {
suite.afterEach('cleanup', runCleanupFunctions);
suite.on('suite', attach);
}
mocha.suite.on('suite', (suite) => {
attach(suite);
suite.afterAll('end of test cleanup', async () => {
const windowsLeftOpen = await closeAllWindows(true);
if (windowsLeftOpen > 0) {
console.log(`WARNING!!!!!!!!!! ${suite.fullTitle()} ${path.basename(suite.file)} left ${windowsLeftOpen} windows open!`);
}
const webContentsDangling = await cleanupWebContents();
if (webContentsDangling > 0) {
console.log(`WARNING!!!!!!!!!! ${suite.fullTitle()} ${path.basename(suite.file)} left ${webContentsDangling} WebContents dangling!`);
}
});
});
if (!process.env.MOCHA_REPORTER) {
@@ -172,14 +185,6 @@ app.whenReady().then(async () => {
const { closeAllWindows, cleanupWebContents } = require('./lib/window-helpers');
const cb = async () => {
const windowsLeftOpen = await closeAllWindows(true);
if (windowsLeftOpen > 0) {
console.log(`WARNING!!!!!!!!!! cleaned up ${windowsLeftOpen} windows open!`);
}
const webContentsDangling = await cleanupWebContents();
if (webContentsDangling > 0) {
console.log(`WARNING!!!!!!!!!! cleaned up ${webContentsDangling} WebContents dangling!`);
}
// Ensure the callback is called after runner is defined
process.nextTick(() => {
process.exit(runner.failures);