MagicMirror/tests/e2e/mock-console.js
2021-09-28 21:10:24 +02:00

22 lines
471 B
JavaScript

/**
* Suppresses errors concerning web server already shut down.
*
* @param {string} err The error message.
*/
function mockError(err) {
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up") || err.includes("exports is not defined")) {
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
};