@@ -25,32 +25,50 @@ module.exports = {
2525 verbose : true ,
2626 cacheDirectory : '<rootDir>/tmp/jest' ,
2727 moduleFileExtensions : [ 'ts' , 'tsx' , 'js' , 'json' ] ,
28+ // preset configs
29+ // preset: 'ts-jest/presets/js-with-ts',
30+ // which files to test and which to ignore
2831 testMatch : [ '**/src/tests/*.test.(ts|tsx)' ] ,
2932 testPathIgnorePatterns : [ '/node_modules/' , '/tmp/' , '/coverage/' , '/stories/' , '/\\.storybook/' ] ,
33+ // don't watch for file changes in node_modules
3034 watchPathIgnorePatterns : [ '/node_modules/' ] ,
35+ // jest automock settings
3136 automock : false ,
3237 unmockedModulePathPatterns : [ '/node_modules/' ] ,
3338 setupFilesAfterEnv : [ './jest.setup.js' ] ,
39+ // test environment setup
40+ // setupFiles: [`${__dirname}/setup/setup.js`],
41+ // setupFilesAfterEnv: [`${__dirname}/setup/setupAfterEnv.ts`],
42+ // coverage settings
3443 collectCoverage : true ,
3544 collectCoverageFrom : [ '**/*.{ts,tsx}' , '!**/*.d.ts' , '!**/node_modules/**' ] ,
3645 coverageThreshold : {
37- global : {
38- branches : 65 ,
39- functions : 80 ,
40- lines : 80 ,
41- statements : 80
46+ " global" : {
47+ " branches" : 65 ,
48+ " functions" : 80 ,
49+ " lines" : 80 ,
50+ " statements" : 80
4251 }
4352 } ,
4453 coveragePathIgnorePatterns : [ '/node_modules/' , '\\.json$' , '/__tests__/' , '/stories/' , '/\\.storybook/' ] ,
4554
46- transform : {
47- '^.+\\.(ts|tsx)$' : [ 'ts -jest', {
55+ globals : {
56+ 'ts -jest' : {
4857 tsconfig : `${ __dirname } /tsconfig.json` ,
58+
59+ // https://huafu.github.io/ts-jest/user/config/diagnostics
4960 diagnostics : false ,
61+
62+ // Makes jest test run much faster, BUT, without type checking.
63+ // Type checking in CI is done with `tsc --noEmit` or `yarn typecheck` command.
64+ // https://huafu.github.io/ts-jest/user/config/isolatedModules
5065 isolatedModules : true ,
51- } ] ,
52- '^.+\\.(js|jsx)$' : 'babel-jest' ,
66+ } ,
5367 } ,
5468
5569 transformIgnorePatterns : [ '/node_modules/(?!(lodash-es|antd|[^/]+/es|rc-animate|rc-util)/).*' ] ,
56- } ;
70+ transform : {
71+ '\\.(ts|tsx)$' : 'ts-jest' ,
72+ '/node_modules/((lodash-es|[^/]+/es)|rc-animate|rc-util)/.*' : 'ts-jest' ,
73+ } ,
74+ } ;
0 commit comments