MagicMirror/tests/e2e/mock-console.js

22 lines
425 B
JavaScript
Raw Normal View History

/**
* Suppresses errors concerning web server already shut down.
*
* @param {string} err The error message.
*/
2021-09-23 00:05:30 +02:00
function myError(err) {
if (err.includes("ECONNREFUSED") || err.includes("ECONNRESET") || err.includes("socket hang up")) {
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,
error: myError,
warn: console.warn,
info: jest.fn(),
debug: console.debug
2021-09-21 23:48:29 +02:00
};