MagicMirror/tests/e2e/helpers/mock-console.js

30 lines
606 B
JavaScript
Raw Normal View History

/**
* 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("write EPIPE") ||
err.includes("AggregateError") ||
err.includes("ERR_SOCKET_CONNECTION_TIMEOUT")
) {
2021-09-23 22:52:32 +02:00
jest.fn();
} else {
console.dir(err);
}
};
2021-09-23 00:05:30 +02:00
2021-09-21 23:48:29 +02:00
global.console = {
2021-09-23 22:52:32 +02:00
log: jest.fn(),
dir: console.dir,
2021-09-28 21:10:24 +02:00
error: mockError,
2021-09-23 22:52:32 +02:00
warn: console.warn,
info: jest.fn(),
debug: console.debug
2021-09-21 23:48:29 +02:00
};