3
3
const path = require ( "path" ) ;
4
4
// eslint-disable-next-line node/no-unpublished-require
5
5
const rimraf = require ( "rimraf" ) ;
6
- const { run, isWebpack5 } = require ( "../../utils/test-utils" ) ;
6
+ const { run } = require ( "../../utils/test-utils" ) ;
7
7
8
8
describe ( "cache" , ( ) => {
9
9
it ( "should work" , async ( ) => {
@@ -14,25 +14,19 @@ describe("cache", () => {
14
14
let { exitCode, stderr, stdout } = await run ( __dirname , [ "-c" , "./webpack.config.js" ] ) ;
15
15
16
16
expect ( exitCode ) . toEqual ( 0 ) ;
17
-
18
- if ( isWebpack5 ) {
19
- expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
20
- expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
21
- expect ( stderr ) . toBeTruthy ( ) ;
22
- expect ( stdout ) . toBeTruthy ( ) ;
23
- }
17
+ expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
18
+ expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
19
+ expect ( stderr ) . toBeTruthy ( ) ;
20
+ expect ( stdout ) . toBeTruthy ( ) ;
24
21
25
22
( { exitCode, stderr, stdout } = await run ( __dirname , [ "-c" , "./webpack.config.js" ] ) ) ;
26
23
27
24
expect ( exitCode ) . toEqual ( 0 ) ;
28
-
29
- if ( isWebpack5 ) {
30
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
31
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
32
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
33
- expect ( stderr ) . toBeTruthy ( ) ;
34
- expect ( stdout ) . toBeTruthy ( ) ;
35
- }
25
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
26
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
27
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
28
+ expect ( stderr ) . toBeTruthy ( ) ;
29
+ expect ( stdout ) . toBeTruthy ( ) ;
36
30
} ) ;
37
31
38
32
it ( "should work in multi compiler mode" , async ( ) => {
@@ -46,25 +40,19 @@ describe("cache", () => {
46
40
let { exitCode, stderr, stdout } = await run ( __dirname , [ "-c" , "./multi.config.js" ] ) ;
47
41
48
42
expect ( exitCode ) . toEqual ( 0 ) ;
49
-
50
- if ( isWebpack5 ) {
51
- expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 2 ) ;
52
- expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 2 ) ;
53
- expect ( stderr ) . toBeTruthy ( ) ;
54
- expect ( stdout ) . toBeTruthy ( ) ;
55
- }
43
+ expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 2 ) ;
44
+ expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 2 ) ;
45
+ expect ( stderr ) . toBeTruthy ( ) ;
46
+ expect ( stdout ) . toBeTruthy ( ) ;
56
47
57
48
( { exitCode, stderr, stdout } = await run ( __dirname , [ "-c" , "./multi.config.js" ] ) ) ;
58
49
59
50
expect ( exitCode ) . toEqual ( 0 ) ;
60
-
61
- if ( isWebpack5 ) {
62
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 2 ) ;
63
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 2 ) ;
64
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 2 ) ;
65
- expect ( stderr ) . toBeTruthy ( ) ;
66
- expect ( stdout ) . toBeTruthy ( ) ;
67
- }
51
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 2 ) ;
52
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 2 ) ;
53
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 2 ) ;
54
+ expect ( stderr ) . toBeTruthy ( ) ;
55
+ expect ( stdout ) . toBeTruthy ( ) ;
68
56
} ) ;
69
57
70
58
it ( "should work in multi compiler mode with the `--config-name` argument" , async ( ) => {
@@ -82,13 +70,10 @@ describe("cache", () => {
82
70
] ) ;
83
71
84
72
expect ( exitCode ) . toEqual ( 0 ) ;
85
-
86
- if ( isWebpack5 ) {
87
- expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
88
- expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
89
- expect ( stderr ) . toBeTruthy ( ) ;
90
- expect ( stdout ) . toBeTruthy ( ) ;
91
- }
73
+ expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
74
+ expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
75
+ expect ( stderr ) . toBeTruthy ( ) ;
76
+ expect ( stdout ) . toBeTruthy ( ) ;
92
77
93
78
( { exitCode, stderr, stdout } = await run ( __dirname , [
94
79
"-c" ,
@@ -100,14 +85,11 @@ describe("cache", () => {
100
85
] ) ) ;
101
86
102
87
expect ( exitCode ) . toEqual ( 0 ) ;
103
-
104
- if ( isWebpack5 ) {
105
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
106
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
107
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
108
- expect ( stderr ) . toBeTruthy ( ) ;
109
- expect ( stdout ) . toBeTruthy ( ) ;
110
- }
88
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
89
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
90
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
91
+ expect ( stderr ) . toBeTruthy ( ) ;
92
+ expect ( stdout ) . toBeTruthy ( ) ;
111
93
} ) ;
112
94
113
95
it ( "should work with the `--merge` argument" , async ( ) => {
@@ -126,13 +108,10 @@ describe("cache", () => {
126
108
] ) ;
127
109
128
110
expect ( exitCode ) . toEqual ( 0 ) ;
129
-
130
- if ( isWebpack5 ) {
131
- expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
132
- expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
133
- expect ( stderr ) . toBeTruthy ( ) ;
134
- expect ( stdout ) . toBeTruthy ( ) ;
135
- }
111
+ expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
112
+ expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
113
+ expect ( stderr ) . toBeTruthy ( ) ;
114
+ expect ( stdout ) . toBeTruthy ( ) ;
136
115
137
116
( { exitCode, stderr, stdout } = await run ( __dirname , [
138
117
"-c" ,
@@ -145,14 +124,11 @@ describe("cache", () => {
145
124
] ) ) ;
146
125
147
126
expect ( exitCode ) . toEqual ( 0 ) ;
148
-
149
- if ( isWebpack5 ) {
150
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
151
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
152
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
153
- expect ( stderr ) . toBeTruthy ( ) ;
154
- expect ( stdout ) . toBeTruthy ( ) ;
155
- }
127
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
128
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
129
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
130
+ expect ( stderr ) . toBeTruthy ( ) ;
131
+ expect ( stdout ) . toBeTruthy ( ) ;
156
132
} ) ;
157
133
158
134
it ( "should work with the `--config-name` and `--merge` argument" , async ( ) => {
@@ -175,13 +151,10 @@ describe("cache", () => {
175
151
] ) ;
176
152
177
153
expect ( exitCode ) . toEqual ( 0 ) ;
178
-
179
- if ( isWebpack5 ) {
180
- expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
181
- expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
182
- expect ( stderr ) . toBeTruthy ( ) ;
183
- expect ( stdout ) . toBeTruthy ( ) ;
184
- }
154
+ expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
155
+ expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
156
+ expect ( stderr ) . toBeTruthy ( ) ;
157
+ expect ( stdout ) . toBeTruthy ( ) ;
185
158
186
159
( { exitCode, stderr, stdout } = await run ( __dirname , [
187
160
"-c" ,
@@ -198,14 +171,11 @@ describe("cache", () => {
198
171
] ) ) ;
199
172
200
173
expect ( exitCode ) . toEqual ( 0 ) ;
201
-
202
- if ( isWebpack5 ) {
203
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
204
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
205
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
206
- expect ( stderr ) . toBeTruthy ( ) ;
207
- expect ( stdout ) . toBeTruthy ( ) ;
208
- }
174
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
175
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
176
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
177
+ expect ( stderr ) . toBeTruthy ( ) ;
178
+ expect ( stdout ) . toBeTruthy ( ) ;
209
179
} ) ;
210
180
211
181
it ( "should work with autoloading configuration" , async ( ) => {
@@ -219,24 +189,18 @@ describe("cache", () => {
219
189
let { exitCode, stderr, stdout } = await run ( __dirname , [ "--name" , "cache-test-autoloading" ] ) ;
220
190
221
191
expect ( exitCode ) . toEqual ( 0 ) ;
222
-
223
- if ( isWebpack5 ) {
224
- expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
225
- expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
226
- expect ( stderr ) . toBeTruthy ( ) ;
227
- expect ( stdout ) . toBeTruthy ( ) ;
228
- }
192
+ expect ( stderr . match ( / N o p a c k e x i s t s a t / g) ) . toHaveLength ( 1 ) ;
193
+ expect ( stderr . match ( / S t o r e d p a c k / g) ) . toHaveLength ( 1 ) ;
194
+ expect ( stderr ) . toBeTruthy ( ) ;
195
+ expect ( stdout ) . toBeTruthy ( ) ;
229
196
230
197
( { exitCode, stderr, stdout } = await run ( __dirname , [ "--name" , "cache-test-autoloading" ] ) ) ;
231
198
232
199
expect ( exitCode ) . toEqual ( 0 ) ;
233
-
234
- if ( isWebpack5 ) {
235
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
236
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
237
- expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
238
- expect ( stderr ) . toBeTruthy ( ) ;
239
- expect ( stdout ) . toBeTruthy ( ) ;
240
- }
200
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t a i n e r : / g) ) . toHaveLength ( 1 ) ;
201
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t m e t a d a t a : / g) ) . toHaveLength ( 1 ) ;
202
+ expect ( stderr . match ( / r e s t o r e c a c h e c o n t e n t \d + \( .+ \) : / g) ) . toHaveLength ( 1 ) ;
203
+ expect ( stderr ) . toBeTruthy ( ) ;
204
+ expect ( stdout ) . toBeTruthy ( ) ;
241
205
} ) ;
242
206
} ) ;
0 commit comments