tachybase_todo/jest.setup.ts
2022-02-15 09:11:00 +08:00

35 lines
756 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';
import yargs from 'yargs';
const envFile = existsSync(resolve(__dirname, '.env.test')) ? '.env.test' : '.env';
dotenv.config({
path: resolve(__dirname, envFile),
});
if (yargs.argv.dbDialect) {
process.env.DB_DIALECT = yargs.argv.dbDialect as any;
}
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();
});
})();