From 76bbdfb1f6a6efea423465d22eb2d9d9d82d2930 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 15 Feb 2022 11:02:56 +0800 Subject: [PATCH] chore(jest): modulePathIgnorePatterns --- jest.cli.js | 9 +++++++++ jest.config.js | 8 +++----- jest.setup.ts | 9 --------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/jest.cli.js b/jest.cli.js index bb39cd9b7..c14e84318 100644 --- a/jest.cli.js +++ b/jest.cli.js @@ -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; } diff --git a/jest.config.js b/jest.config.js index 71ebb34f1..2c327d6a9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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: '/', }), @@ -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', ], -} +}; diff --git a/jest.setup.ts b/jest.setup.ts index bcf800201..5b3e4dfa0 100644 --- a/jest.setup.ts +++ b/jest.setup.ts @@ -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);