File tree 3 files changed +17
-13
lines changed
packages/jest-cli/src/init
3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 4
4
5
5
### Fixes
6
6
7
+ - ` [jest-cli] ` Use correct file name to override existing jest config on init ([ #10337 ] ( https://github.com/facebook/jest/pull/10337 ) )
8
+
7
9
### Chore & Maintenance
8
10
9
11
### Performance
Original file line number Diff line number Diff line change @@ -175,8 +175,10 @@ describe('init', () => {
175
175
176
176
expect ( prompts . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( ) ;
177
177
178
+ const jestConfigFileName = fs . writeFileSync . mock . calls [ 0 ] [ 0 ] ;
178
179
const writtenJestConfig = fs . writeFileSync . mock . calls [ 0 ] [ 1 ] ;
179
180
181
+ expect ( jestConfigFileName ) . toBe ( `jest.config.${ extension } ` ) ;
180
182
expect ( writtenJestConfig ) . toBeDefined ( ) ;
181
183
} ) ;
182
184
Original file line number Diff line number Diff line change @@ -61,21 +61,21 @@ export default async (
61
61
hasJestProperty = true ;
62
62
}
63
63
64
- const existingJestConfigPath = JEST_CONFIG_EXT_ORDER . find ( ext =>
64
+ const existingJestConfigExt = JEST_CONFIG_EXT_ORDER . find ( ext =>
65
65
fs . existsSync ( path . join ( rootDir , getConfigFilename ( ext ) ) ) ,
66
66
) ;
67
- const jestConfigPath =
68
- existingJestConfigPath ||
69
- path . join (
70
- rootDir ,
71
- getConfigFilename (
72
- projectPackageJson . type === 'module'
73
- ? JEST_CONFIG_EXT_MJS
74
- : JEST_CONFIG_EXT_JS ,
75
- ) ,
76
- ) ;
77
-
78
- if ( hasJestProperty || existingJestConfigPath ) {
67
+ const jestConfigPath = existingJestConfigExt
68
+ ? getConfigFilename ( existingJestConfigExt )
69
+ : path . join (
70
+ rootDir ,
71
+ getConfigFilename (
72
+ projectPackageJson . type === 'module'
73
+ ? JEST_CONFIG_EXT_MJS
74
+ : JEST_CONFIG_EXT_JS ,
75
+ ) ,
76
+ ) ;
77
+
78
+ if ( hasJestProperty || existingJestConfigExt ) {
79
79
const result : { continue : boolean } = await prompts ( {
80
80
initial : true ,
81
81
message :
You can’t perform that action at this time.
0 commit comments