@@ -8,65 +8,71 @@ interface IJestConfig extends Jest.Config.InitialOptions {
8
8
export default ( resolve : Function , rootDir : string ) => {
9
9
const conf : IJestConfig = {
10
10
rootDir : rootDir ,
11
- /**
12
- * Alias: -w. Specifies the maximum number of workers the worker-pool will spawn for running tests.
13
- * In single run mode, this defaults to the number of the cores available on your machine minus one for the main thread.
14
- * In watch mode, this defaults to half of the available cores on your machine to ensure Jest is unobtrusive and does not grind your machine to a halt.
15
- * It may be useful to adjust this in resource limited environments like CIs but the defaults should be adequate for most use-cases.
16
- * For environments with variable CPUs available, you can use percentage based configuration: --maxWorkers=50%
17
- */
18
- maxWorkers : '50%' ,
19
- collectCoverageFrom : [ 'src/**/*.{ts,tsx}' , '!src/**/*.d.ts' ] ,
20
- testMatch : [ '<rootDir>/**/__tests__/**/*.{js,jsx,ts,tsx}' , '<rootDir>/**/?(*.)(spec|test).{js,jsx,ts,tsx}' ] ,
21
- testURL : 'http://localhost' ,
11
+ collectCoverageFrom : [ 'src/**/*.{js,jsx,ts,tsx}' , '!src/**/*.d.ts' ] ,
12
+ testMatch : [ '<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}' , '<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}' ] ,
13
+ testEnvironment : 'jsdom' ,
14
+ testRunner : require . resolve ( 'jest-circus/runner' ) ,
22
15
transform : {
23
- '^.+\\.(js|jsx|ts|tsx)$' : resolve ( 'lib/jest/babelTransform.js' ) ,
24
- '^.+\\.( css|less|sass|scss) $' : resolve ( 'lib/jest/cssTransform.js' ) ,
25
- '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)' : resolve ( 'lib/jest/fileTransform.js' ) ,
16
+ '^.+\\.(js|jsx|mjs|cjs| ts|tsx)$' : resolve ( 'lib/jest/babelTransform.js' ) ,
17
+ '^.+\\.css$' : resolve ( 'lib/jest/cssTransform.js' ) ,
18
+ '^(?!.*\\.(js|jsx|mjs|cjs| ts|tsx|css|json)$)' : resolve ( 'lib/jest/fileTransform.js' ) ,
26
19
} ,
27
- transformIgnorePatterns : [ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$' ] ,
20
+ transformIgnorePatterns : [
21
+ '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$' ,
22
+ '^.+\\.module\\.(css|less|styl|sass|scss)$' ,
23
+ ] ,
28
24
moduleNameMapper : {
29
- '^.+\\.module\\.(css|less|sass|scss)$' : 'identity-obj-proxy' ,
25
+ '^react-native$' : 'react-native-web' ,
26
+ '^.+\\.module\\.(css|sass|scss)$' : 'identity-obj-proxy' ,
30
27
} ,
28
+ watchPlugins : [ 'jest-watch-typeahead/filename' , 'jest-watch-typeahead/testname' ] ,
29
+ resetMocks : true ,
31
30
} ;
32
31
33
32
const overrides : IJestConfig = Object . assign ( { } , require ( path . join ( rootDir , 'package.json' ) ) . jest ) ;
34
33
35
34
if ( overrides ) {
36
35
const supportedKeys : string [ ] = [
36
+ 'clearMocks' ,
37
37
'collectCoverageFrom' ,
38
+ 'coveragePathIgnorePatterns' ,
38
39
'coverageReporters' ,
39
40
'coverageThreshold' ,
40
- 'globals ' ,
41
- 'mapCoverage ' ,
42
- 'moduleFileExtensions ' ,
43
- 'modulePathIgnorePatterns ' ,
41
+ 'displayName ' ,
42
+ 'extraGlobals ' ,
43
+ 'globalSetup ' ,
44
+ 'globalTeardown ' ,
44
45
'moduleNameMapper' ,
45
- 'modulePaths' ,
46
+ 'resetMocks' ,
47
+ 'resetModules' ,
48
+ 'restoreMocks' ,
46
49
'snapshotSerializers' ,
47
- 'setupFiles' ,
48
50
'testMatch' ,
49
- 'testEnvironmentOptions' ,
50
- 'testResultsProcessor' ,
51
51
'transform' ,
52
52
'transformIgnorePatterns' ,
53
- 'reporters ' ,
53
+ 'watchPathIgnorePatterns ' ,
54
54
] ;
55
55
supportedKeys . forEach ( ( key : string ) => {
56
56
if ( overrides . hasOwnProperty ( key ) ) {
57
- conf [ key ] = overrides [ key ] ;
57
+ if ( Array . isArray ( conf [ key ] ) || typeof conf [ key ] !== 'object' ) {
58
+ // for arrays or primitive types, directly override the config key
59
+ conf [ key ] = overrides [ key ] ;
60
+ } else {
61
+ // for object types, extend gracefully
62
+ conf [ key ] = Object . assign ( { } , conf [ key ] , overrides [ key ] ) ;
63
+ }
58
64
delete overrides [ key ] ;
59
65
}
60
66
} ) ;
61
67
const unsupportedKeys = Object . keys ( overrides ) ;
62
68
if ( unsupportedKeys . length ) {
63
69
console . error (
64
- '\x1b[1;31mOut of the box, kkt only supports overriding \x1b[0m' +
70
+ '\x1b[1;31mOut of the box, TSBB only supports overriding \x1b[0m' +
65
71
'\x1b[1;31mthese Jest options:\x1b[0m\n\n' +
66
72
supportedKeys . map ( ( key ) => ' \u2022 ' + key ) . join ( '\n' ) +
67
73
'.\n\n' +
68
74
'\x1b[1;31mThese options in your package.json Jest configuration \x1b[0m' +
69
- '\x1b[1;31mare not currently supported by kkt :\x1b[0m\n\n' +
75
+ '\x1b[1;31mare not currently supported by TSBB App :\x1b[0m\n\n' +
70
76
unsupportedKeys . map ( ( key ) => ' \u2022 ' + key ) . join ( '\n' ) ,
71
77
) ;
72
78
process . exit ( 1 ) ;
0 commit comments