tachybase_todo/jest.setup.ts

30 lines
644 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import dotenv from 'dotenv';
import { existsSync } from 'fs';
import { resolve } from 'path';
import prettyFormat from 'pretty-format';
const envFile = existsSync(resolve(__dirname, '.env.test')) ? '.env.test' : '.env';
dotenv.config({
path: resolve(__dirname, envFile),
});
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();
});
})();