diff --git a/jest.cli.js b/jest.cli.js index bb39cd9b7c..c14e843183 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 71ebb34f19..2c327d6a9f 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 bcf8002016..5b3e4dfa07 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);