Skip to content

Commit ec41571

Browse files
realyuyananmapleeit
authored andcommitted
test(winston): fix test error
1 parent 67a64c8 commit ec41571

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/core/__test__/winston.test.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1+
import * as winston from "winston";
12
import { winstonHack } from "../winston";
23
import logger from "../../core/logger/index";
34

5+
global.tswConfig = {
6+
plugins: [],
7+
winstonTransports: undefined
8+
};
9+
410
describe("test winstonHack env", () => {
511
test("test logger's winstonLogger when it hasn't hacked", () => {
612
expect(logger.winstonLogger).toBe(undefined);
713
});
814

9-
global.tswConfig.winstonTransports = undefined;
10-
winstonHack();
1115
test("test winstonHack while config without winstonTransports ", () => {
12-
expect(logger.winstonLogger.log).toBe(undefined);
16+
winstonHack();
17+
expect(logger.winstonLogger).toBe(undefined);
18+
});
19+
20+
21+
test("test winstonHack while config with Console Transports ", () => {
22+
global.tswConfig.winstonTransports = [
23+
new winston.transports.Console()
24+
];
25+
26+
winstonHack();
27+
expect(logger.winstonLogger.transports.length).toBe(1);
1328
});
1429
});

0 commit comments

Comments
 (0)