chore(jest): modulePathIgnorePatterns

This commit is contained in:
chenos 2022-02-15 11:02:56 +08:00
parent d81d1979b0
commit 76bbdfb1f6
3 changed files with 12 additions and 14 deletions

View File

@ -1,5 +1,14 @@
const dotenv = require('dotenv');
const { existsSync } = require('fs');
const { resolve } = require('path')
const yargs = require('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;
}

View File

@ -7,10 +7,7 @@ module.exports = {
testEnvironment: 'jsdom',
preset: 'ts-jest',
testMatch: ['**/__tests__/**/*.test.[jt]s?(x)'],
setupFilesAfterEnv: [
require.resolve('jest-dom/extend-expect'),
'./jest.setup.ts',
],
setupFilesAfterEnv: [require.resolve('jest-dom/extend-expect'), './jest.setup.ts'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),
@ -21,6 +18,7 @@ module.exports = {
diagnostics: false,
},
},
modulePathIgnorePatterns: ['/esm/', '/lib/'],
coveragePathIgnorePatterns: [
'/node_modules/',
'/__tests__/',
@ -30,4 +28,4 @@ module.exports = {
'/demo/',
'package-lock.json',
],
}
};

View File

@ -1,14 +1,5 @@
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);