File tree Expand file tree Collapse file tree
e2e/__tests__/__snapshots__
jest-resolve-dependencies/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33### Fixes
44
55- ` [jest-runner] ` Force parallel runs for watch mode, to avoid TTY freeze ([ #6647 ] ( https://github.com/facebook/jest/pull/6647 ) )
6+ - ` [jest-cli] ` properly reprint resolver errors in watch mode ([ #6407 ] ( https://github.com/facebook/jest/pull/6407 ) )
67- ` [jest-cli] ` Fix ` testMatch ` not working with negations ([ #6648 ] ( https://github.com/facebook/jest/pull/6648 ) )
78
89## 23.3.0
Original file line number Diff line number Diff line change @@ -13,14 +13,27 @@ exports[`moduleNameMapper wrong configuration 1`] = `
1313
1414 Configuration error:
1515
16- Could not locate module ./style.css (mapped as no-such-module)
17-
18- Please check:
19-
20- \\ "moduleNameMapper\\ ": {
21- \\" /\\\\ .(css|less)$/\\ " : \\" no-such-module\\ "
22- } ,
23- \\ "resolver\\ ": null
16+ Could not locate module ./style.css mapped as:
17+ no-such-module.
18+
19+ Please check your configuration for these entries:
20+ {
21+ \\" moduleNameMapper\\ " : {
22+ \\" /\\\\ .(css|less)$/\\ " : \\" no-such-module\\ "
23+ },
24+ \\" resolver\\ " : null
25+ }
26+
27+ 8 | 'use strict';
28+ 9 |
29+ > 10 | require('./style.css');
30+ | ^
31+ 11 |
32+ 12 | module.exports = () => 'test';
33+ 13 |
34+
35+ at packages/jest-resolve/build/index.js:400:17
36+ at index.js:10:1
2437
2538"
2639` ;
Original file line number Diff line number Diff line change @@ -236,7 +236,13 @@ export default function watch(
236236 outputStream,
237237 startRun,
238238 testWatcher,
239- } ) . catch ( error => console . error ( chalk . red ( error . stack ) ) ) ;
239+ } ) . catch ( error =>
240+ // Errors thrown inside `runJest`, e.g. by resolvers, are caught here for
241+ // continuous watch mode execution. We need to reprint them to the
242+ // terminal and give just a little bit of extra space so they fit below
243+ // `preRunMessagePrint` message nicely.
244+ console . error ( '\n\n' + chalk . red ( error ) ) ,
245+ ) ;
240246 } ;
241247
242248 const onKeypress = ( key : string ) => {
Original file line number Diff line number Diff line change @@ -100,7 +100,6 @@ class DependencyResolver {
100100 }
101101 }
102102 }
103-
104103 const modules = this . _hasteFS . getAllFiles ( ) . map ( file => ( {
105104 dependencies : this . resolve ( file , options ) ,
106105 file,
Original file line number Diff line number Diff line change @@ -352,22 +352,13 @@ class Resolver {
352352 rootDir : this . _options . rootDir ,
353353 } ) ;
354354 if ( ! module ) {
355- const error = new Error (
356- chalk . red ( `${ chalk . bold ( 'Configuration error' ) } :
357-
358- Could not locate module ${ chalk . bold ( moduleName ) } (mapped as ${ chalk . bold (
359- updatedName ,
360- ) } )
361-
362- Please check:
363-
364- "moduleNameMapper": {
365- "${ regex . toString ( ) } ": "${ chalk . bold ( mappedModuleName ) } "
366- },
367- "resolver": ${ chalk . bold ( String ( resolver ) ) } ` ) ,
355+ throw createNoMappedModuleFoundError (
356+ moduleName ,
357+ updatedName ,
358+ mappedModuleName ,
359+ regex ,
360+ resolver ,
368361 ) ;
369- error . stack = '' ;
370- throw error ;
371362 }
372363 return module ;
373364 }
@@ -381,4 +372,31 @@ Please check:
381372 }
382373}
383374
375+ const createNoMappedModuleFoundError = (
376+ moduleName ,
377+ updatedName ,
378+ mappedModuleName ,
379+ regex ,
380+ resolver ,
381+ ) => {
382+ const error = new Error (
383+ chalk . red ( `${ chalk . bold ( 'Configuration error' ) } :
384+
385+ Could not locate module ${ chalk . bold ( moduleName ) } mapped as:
386+ ${ chalk . bold ( updatedName ) } .
387+
388+ Please check your configuration for these entries:
389+ {
390+ "moduleNameMapper": {
391+ "${ regex . toString ( ) } ": "${ chalk . bold ( mappedModuleName ) } "
392+ },
393+ "resolver": ${ chalk . bold ( String ( resolver ) ) }
394+ }` ) ,
395+ ) ;
396+
397+ error . name = '' ;
398+
399+ return error ;
400+ } ;
401+
384402module . exports = Resolver ;
You can’t perform that action at this time.
0 commit comments