MagicMirror/tests/e2e/helpers/mock-console.js
Karsten Hassel d2d4d7b37f
update jest to v30 (#3815)
e2e:
- needed window.close(), otherwise the objects are not destroyed
- add missing `await` in clock test
- set maxListeners for all tests

remaining todo (comes with another PR if I find the problem):
- calendar e2e is now the only test which still needs `--forceExit`
2025-06-21 13:40:10 +02:00

32 lines
675 B
JavaScript

/**
* Suppresses errors concerning web server already shut down.
* @param {string} err The error message.
*/
const mockError = (err) => {
if (
err.includes("ECONNREFUSED")
|| err.includes("ECONNRESET")
|| err.includes("socket hang up")
|| err.includes("exports is not defined")
|| err.includes("module is not defined")
|| err.includes("write EPIPE")
|| err.includes("AggregateError")
|| err.includes("ERR_SOCKET_CONNECTION_TIMEOUT")
) {
jest.fn();
} else {
console.dir(err);
}
};
global.console = {
log: jest.fn(),
dir: console.dir,
error: mockError,
warn: console.warn,
info: jest.fn(),
debug: console.debug
};
process.setMaxListeners(0);