2021-09-24 23:39:12 +02:00
|
|
|
/**
|
|
|
|
* Suppresses errors concerning web server already shut down.
|
|
|
|
*
|
|
|
|
* @param {string} err The error message.
|
|
|
|
*/
|
2022-10-04 10:15:24 +02:00
|
|
|
const mockError = (err) => {
|
2023-04-22 09:29:23 +02:00
|
|
|
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);
|
|
|
|
}
|
2022-10-04 10:15:24 +02:00
|
|
|
};
|
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
|
|
|
};
|