tachybase_todo/jest.setup.ts

27 lines
545 B
TypeScript
Raw Normal View History

2021-12-06 21:23:34 +08:00
import path from 'path';
import dotenv from 'dotenv';
import prettyFormat from 'pretty-format';
dotenv.config({
path: path.resolve(__dirname, process.env.ENV_FILE || '.env'),
});
global['prettyFormat'] = prettyFormat;
jest.setTimeout(300000);
// 把 console.error 转换成 error方便断言
(() => {
const spy = jest.spyOn(console, 'error');
beforeAll(() => {
spy.mockImplementation((message) => {
console.log(message);
throw new Error(message);
});
});
afterAll(() => {
spy.mockRestore();
});
})();