mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-11-29 18:58:26 +08:00
test: should load the .env.test (#1678)
This commit is contained in:
parent
bbc2db424f
commit
39204e8149
@ -9,8 +9,8 @@ module.exports = {
|
||||
testEnvironment: 'jsdom',
|
||||
preset: 'ts-jest',
|
||||
testMatch: ['**/__tests__/**/*.test.[jt]s?(x)'],
|
||||
setupFiles: ['dotenv/config'],
|
||||
setupFilesAfterEnv: [require.resolve('jest-dom/extend-expect'), './jest.setup.ts'],
|
||||
setupFiles: ['./jest.setup.ts'],
|
||||
setupFilesAfterEnv: [require.resolve('jest-dom/extend-expect'), './jest.setupAfterEnv.ts'],
|
||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
|
||||
prefix: '<rootDir>/',
|
||||
}),
|
||||
|
@ -1,13 +1,4 @@
|
||||
import prettyFormat from 'pretty-format';
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
|
||||
global['prettyFormat'] = prettyFormat;
|
||||
|
||||
jest.setTimeout(300000);
|
||||
|
||||
// 把 console.error 转换成 error,方便断言
|
||||
(() => {
|
||||
const spy = jest.spyOn(console, 'error');
|
||||
afterAll(() => {
|
||||
spy.mockRestore();
|
||||
});
|
||||
})();
|
||||
dotenv.config({ path: path.resolve(process.cwd(), '.env.test') });
|
||||
|
13
jest.setupAfterEnv.ts
Normal file
13
jest.setupAfterEnv.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import prettyFormat from 'pretty-format';
|
||||
|
||||
global['prettyFormat'] = prettyFormat;
|
||||
|
||||
jest.setTimeout(300000);
|
||||
|
||||
// 把 console.error 转换成 error,方便断言
|
||||
(() => {
|
||||
const spy = jest.spyOn(console, 'error');
|
||||
afterAll(() => {
|
||||
spy.mockRestore();
|
||||
});
|
||||
})();
|
Loading…
Reference in New Issue
Block a user