nocobase/jest.setup.ts

27 lines
545 B
TypeScript
Raw Normal View History

2021-12-06 13:23:34 +00: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();
});
})();