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

View File

@ -7,10 +7,7 @@ module.exports = {
testEnvironment: 'jsdom', testEnvironment: 'jsdom',
preset: 'ts-jest', preset: 'ts-jest',
testMatch: ['**/__tests__/**/*.test.[jt]s?(x)'], testMatch: ['**/__tests__/**/*.test.[jt]s?(x)'],
setupFilesAfterEnv: [ setupFilesAfterEnv: [require.resolve('jest-dom/extend-expect'), './jest.setup.ts'],
require.resolve('jest-dom/extend-expect'),
'./jest.setup.ts',
],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/', prefix: '<rootDir>/',
}), }),
@ -21,6 +18,7 @@ module.exports = {
diagnostics: false, diagnostics: false,
}, },
}, },
modulePathIgnorePatterns: ['/esm/', '/lib/'],
coveragePathIgnorePatterns: [ coveragePathIgnorePatterns: [
'/node_modules/', '/node_modules/',
'/__tests__/', '/__tests__/',
@ -30,4 +28,4 @@ module.exports = {
'/demo/', '/demo/',
'package-lock.json', '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'; import prettyFormat from 'pretty-format';
const envFile = existsSync(resolve(__dirname, '.env.test')) ? '.env.test' : '.env';
dotenv.config({
path: resolve(__dirname, envFile),
});
global['prettyFormat'] = prettyFormat; global['prettyFormat'] = prettyFormat;
jest.setTimeout(300000); jest.setTimeout(300000);