@@ -4,24 +4,69 @@ const expect = require('expect');
44it ( 'Formats module-not-found errors' , ( ) => {
55 const error = { type : 'module-not-found' , module : 'redux' } ;
66 expect ( moduleNotFound ( [ error ] ) ) . toEqual ( [
7- 'This dependency was not found in node_modules :' ,
7+ 'This module was not found:' ,
88 '' ,
99 '* redux' ,
1010 '' ,
11- 'Did you forget to run npm install --save for it? '
11+ 'To install it, you can run: npm install --save redux '
1212 ] ) ;
1313} ) ;
1414
1515it ( 'Groups all module-not-found into one' , ( ) => {
1616 const reduxError = { type : 'module-not-found' , module : 'redux' } ;
1717 const reactError = { type : 'module-not-found' , module : 'react' } ;
1818 expect ( moduleNotFound ( [ reduxError , reactError ] ) ) . toEqual ( [
19- 'These dependencies were not found in node_modules :' ,
19+ 'These modules were not found:' ,
2020 '' ,
2121 '* redux' ,
2222 '* react' ,
2323 '' ,
24- 'Did you forget to run npm install --save for them?'
24+ 'To install them, you can run: npm install --save redux react'
25+ ] ) ;
26+ } ) ;
27+
28+ it ( 'Groups same module in module-not-found with 2 files' , ( ) => {
29+ const reduxError = { type : 'module-not-found' , module : 'redux' } ;
30+ const reactError1 = { type : 'module-not-found' , module : 'react' , file : './src/file1.js' } ;
31+ const reactError2 = { type : 'module-not-found' , module : 'react' , file : './src/file2.js' } ;
32+ expect ( moduleNotFound ( [ reduxError , reactError1 , reactError2 ] ) ) . toEqual ( [
33+ 'These modules were not found:' ,
34+ '' ,
35+ '* redux' ,
36+ '* react in ./src/file1.js, ./src/file2.js' ,
37+ '' ,
38+ 'To install them, you can run: npm install --save redux react'
39+ ] ) ;
40+ } ) ;
41+
42+ it ( 'Groups same module in module-not-found with 3 files' , ( ) => {
43+ const reduxError = { type : 'module-not-found' , module : 'redux' } ;
44+ const reactError1 = { type : 'module-not-found' , module : 'react' , file : './src/file1.js' } ;
45+ const reactError2 = { type : 'module-not-found' , module : 'react' , file : './src/file2.js' } ;
46+ const reactError3 = { type : 'module-not-found' , module : 'react' , file : './src/file3.js' } ;
47+ expect ( moduleNotFound ( [ reduxError , reactError1 , reactError2 , reactError3 ] ) ) . toEqual ( [
48+ 'These modules were not found:' ,
49+ '' ,
50+ '* redux' ,
51+ '* react in ./src/file1.js, ./src/file2.js and 1 other' ,
52+ '' ,
53+ 'To install them, you can run: npm install --save redux react'
54+ ] ) ;
55+ } ) ;
56+
57+ it ( 'Groups same module in module-not-found with 4 files' , ( ) => {
58+ const reduxError = { type : 'module-not-found' , module : 'redux' } ;
59+ const reactError1 = { type : 'module-not-found' , module : 'react' , file : './src/file1.js' } ;
60+ const reactError2 = { type : 'module-not-found' , module : 'react' , file : './src/file2.js' } ;
61+ const reactError3 = { type : 'module-not-found' , module : 'react' , file : './src/file3.js' } ;
62+ const reactError4 = { type : 'module-not-found' , module : 'react' , file : './src/file4.js' } ;
63+ expect ( moduleNotFound ( [ reduxError , reactError1 , reactError2 , reactError3 , reactError4 ] ) ) . toEqual ( [
64+ 'These modules were not found:' ,
65+ '' ,
66+ '* redux' ,
67+ '* react in ./src/file1.js, ./src/file2.js and 2 others' ,
68+ '' ,
69+ 'To install them, you can run: npm install --save redux react'
2570 ] ) ;
2671} ) ;
2772
0 commit comments