front-dev/api/test/__mocks__/logger.js

61 lines
1.3 KiB
JavaScript
Raw Normal View History

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();
mockFormatFunction.json = 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(),
File: 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',
};
});
});
jest.mock('~/config', () => {
return {
logger: {
info: jest.fn(),
warn: jest.fn(),
debug: jest.fn(),
error: jest.fn(),
},
};
});
jest.mock('~/config/parsers', () => {
return {
redactMessage: jest.fn(),
redactFormat: jest.fn(),
debugTraverse: jest.fn(),
};
});