-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide support for custom jest configuration files
- Loading branch information
Zakhar Dolozhevskiy
committed
Aug 23, 2021
1 parent
7e65196
commit 3d9fa32
Showing
4 changed files
with
45 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,3 @@ | ||
import path from 'path' | ||
import '@/utils/globals' | ||
|
||
import { loadConfig } from '@/utils' | ||
import mhyConfig from '@/configs/mhy' | ||
|
||
const jestConfig = loadConfig('jest', { | ||
setupFilesAfterEnv: [path.resolve(__dirname, './setup.js')], | ||
rootDir: process.cwd(), | ||
roots: [path.resolve(process.cwd(), mhyConfig.srcFolder)], | ||
watchPathIgnorePatterns: ['__.*__'], | ||
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'], | ||
modulePaths: [ | ||
path.resolve(process.cwd(), mhyConfig.srcFolder), | ||
path.resolve(process.cwd(), 'node_modules'), | ||
path.resolve(__dirname, '../../../node_modules') | ||
], | ||
transform: { | ||
'^.+\\.[jt]sx?$': require.resolve('./preprocess') | ||
}, | ||
transformIgnorePatterns: [], | ||
bail: true, | ||
testRegex: '\\.?(test|tests|spec|integration)\\.[jt]sx?$', | ||
collectCoverage: false, | ||
verbose: true, | ||
moduleNameMapper: { | ||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': 'identity-obj-proxy', | ||
'\\.(s?css|less)$': 'identity-obj-proxy', | ||
'\\.(svgx?)$': path.resolve(__dirname, 'mocks/react-null.js') | ||
}, | ||
collectCoverageFrom: ['**/*.js'], | ||
watchPlugins: [] | ||
}) | ||
|
||
export default jestConfig | ||
export default from './loader' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import path from 'path' | ||
|
||
import { loadConfig } from '@/utils' | ||
import mhyConfig from '@/configs/mhy' | ||
|
||
const srcPath = path.join(process.cwd(), mhyConfig.srcFolder) | ||
|
||
const jestConfig = loadConfig('jest', { | ||
setupFilesAfterEnv: [ | ||
path.resolve(__dirname, './setup.js'), | ||
...require.context(srcPath, true, /jest\.setup\.[jt]sx?$/).keys() | ||
], | ||
rootDir: process.cwd(), | ||
roots: [srcPath], | ||
watchPathIgnorePatterns: ['__.*__'], | ||
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'], | ||
modulePaths: [ | ||
path.resolve(process.cwd(), mhyConfig.srcFolder), | ||
path.resolve(process.cwd(), 'node_modules'), | ||
path.resolve(__dirname, '../../../node_modules') | ||
], | ||
transform: { | ||
'^.+\\.[jt]sx?$': require.resolve('./preprocess') | ||
}, | ||
transformIgnorePatterns: [], | ||
bail: true, | ||
testRegex: '\\.?(test|tests|spec|integration)\\.[jt]sx?$', | ||
collectCoverage: false, | ||
verbose: true, | ||
moduleNameMapper: { | ||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': 'identity-obj-proxy', | ||
'\\.(s?css|less)$': 'identity-obj-proxy', | ||
'\\.(svgx?)$': path.resolve(__dirname, 'mocks/react-null.js') | ||
}, | ||
collectCoverageFrom: ['**/*.js'], | ||
watchPlugins: [] | ||
}) | ||
|
||
export default jestConfig |