@@ -4,24 +4,69 @@ const expect = require('expect');
4
4
it ( 'Formats module-not-found errors' , ( ) => {
5
5
const error = { type : 'module-not-found' , module : 'redux' } ;
6
6
expect ( moduleNotFound ( [ error ] ) ) . toEqual ( [
7
- 'This dependency was not found in node_modules :' ,
7
+ 'This module was not found:' ,
8
8
'' ,
9
9
'* redux' ,
10
10
'' ,
11
- 'Did you forget to run npm install --save for it? '
11
+ 'To install it, you can run: npm install --save redux '
12
12
] ) ;
13
13
} ) ;
14
14
15
15
it ( 'Groups all module-not-found into one' , ( ) => {
16
16
const reduxError = { type : 'module-not-found' , module : 'redux' } ;
17
17
const reactError = { type : 'module-not-found' , module : 'react' } ;
18
18
expect ( moduleNotFound ( [ reduxError , reactError ] ) ) . toEqual ( [
19
- 'These dependencies were not found in node_modules :' ,
19
+ 'These modules were not found:' ,
20
20
'' ,
21
21
'* redux' ,
22
22
'* react' ,
23
23
'' ,
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'
25
70
] ) ;
26
71
} ) ;
27
72
0 commit comments