mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 20:49:54 +00:00
Even in successful tests, there are many module not defined` error entries. Like this: https://github.com/MagicMirrorOrg/MagicMirror/actions/runs/12199106844/job/34032254241#step:5:353 I think we can suppress them.
30 lines
646 B
JavaScript
30 lines
646 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
|
|
};
|