mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:35:20 +00: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',
|
testEnvironment: 'jsdom',
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
testMatch: ['**/__tests__/**/*.test.[jt]s?(x)'],
|
testMatch: ['**/__tests__/**/*.test.[jt]s?(x)'],
|
||||||
setupFiles: ['dotenv/config'],
|
setupFiles: ['./jest.setup.ts'],
|
||||||
setupFilesAfterEnv: [require.resolve('jest-dom/extend-expect'), './jest.setup.ts'],
|
setupFilesAfterEnv: [require.resolve('jest-dom/extend-expect'), './jest.setupAfterEnv.ts'],
|
||||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
|
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
|
||||||
prefix: '<rootDir>/',
|
prefix: '<rootDir>/',
|
||||||
}),
|
}),
|
||||||
|
@ -1,13 +1,4 @@
|
|||||||
import prettyFormat from 'pretty-format';
|
import dotenv from 'dotenv';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
global['prettyFormat'] = prettyFormat;
|
dotenv.config({ path: path.resolve(process.cwd(), '.env.test') });
|
||||||
|
|
||||||
jest.setTimeout(300000);
|
|
||||||
|
|
||||||
// 把 console.error 转换成 error,方便断言
|
|
||||||
(() => {
|
|
||||||
const spy = jest.spyOn(console, 'error');
|
|
||||||
afterAll(() => {
|
|
||||||
spy.mockRestore();
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
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