2024-01-11 11:37:54 -05:00
|
|
|
jest.mock('winston', () => {
|
|
|
|
|
const mockFormatFunction = jest.fn((fn) => fn);
|
|
|
|
|
|
|
|
|
|
mockFormatFunction.colorize = jest.fn();
|
|
|
|
|
mockFormatFunction.combine = jest.fn();
|
|
|
|
|
mockFormatFunction.label = jest.fn();
|
|
|
|
|
mockFormatFunction.timestamp = jest.fn();
|
|
|
|
|
mockFormatFunction.printf = jest.fn();
|
|
|
|
|
mockFormatFunction.errors = jest.fn();
|
|
|
|
|
mockFormatFunction.splat = jest.fn();
|
|
|
|
|
return {
|
|
|
|
|
format: mockFormatFunction,
|
|
|
|
|
createLogger: jest.fn().mockReturnValue({
|
|
|
|
|
info: jest.fn(),
|
|
|
|
|
warn: jest.fn(),
|
|
|
|
|
debug: jest.fn(),
|
|
|
|
|
error: jest.fn(),
|
|
|
|
|
}),
|
|
|
|
|
transports: {
|
|
|
|
|
Console: jest.fn(),
|
|
|
|
|
DailyRotateFile: jest.fn(),
|
|
|
|
|
},
|
|
|
|
|
addColors: jest.fn(),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jest.mock('winston-daily-rotate-file', () => {
|
|
|
|
|
return jest.fn().mockImplementation(() => {
|
|
|
|
|
return {
|
|
|
|
|
level: 'error',
|
|
|
|
|
filename: '../logs/error-%DATE%.log',
|
|
|
|
|
datePattern: 'YYYY-MM-DD',
|
|
|
|
|
zippedArchive: true,
|
|
|
|
|
maxSize: '20m',
|
|
|
|
|
maxFiles: '14d',
|
|
|
|
|
format: 'format',
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2023-12-14 07:49:27 -05:00
|
|
|
jest.mock('~/config', () => {
|
2025-03-10 17:23:46 -04:00
|
|
|
const actualModule = jest.requireActual('~/config');
|
2023-12-14 07:49:27 -05:00
|
|
|
return {
|
2025-03-10 17:23:46 -04:00
|
|
|
sendEvent: actualModule.sendEvent,
|
|
|
|
|
createAxiosInstance: actualModule.createAxiosInstance,
|
2023-12-14 07:49:27 -05:00
|
|
|
logger: {
|
|
|
|
|
info: jest.fn(),
|
|
|
|
|
warn: jest.fn(),
|
|
|
|
|
debug: jest.fn(),
|
|
|
|
|
error: jest.fn(),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
});
|
2024-01-11 11:37:54 -05:00
|
|
|
|
|
|
|
|
jest.mock('~/config/parsers', () => {
|
|
|
|
|
return {
|
|
|
|
|
redactMessage: jest.fn(),
|
|
|
|
|
redactFormat: jest.fn(),
|
|
|
|
|
debugTraverse: jest.fn(),
|
|
|
|
|
};
|
|
|
|
|
});
|