@@ -7,13 +7,6 @@ import path from 'path';
7
7
import webpack from 'webpack' ;
8
8
import del from 'del' ;
9
9
10
- const fileSystemCacheDirectory = path . resolve (
11
- __dirname ,
12
- './outputs/cache/type-filesystem'
13
- ) ;
14
-
15
- del . sync ( fileSystemCacheDirectory ) ;
16
-
17
10
describe ( 'TestCache' , ( ) => {
18
11
afterEach ( ( ) => {
19
12
jest . clearAllMocks ( ) ;
@@ -43,12 +36,18 @@ describe('TestCache', () => {
43
36
directoryForCase ,
44
37
'webpack.config.js'
45
38
) ) ;
39
+ const outputPath = path . resolve ( __dirname , 'js/cache-false' ) ;
40
+
41
+ await del ( [ outputPath ] ) ;
46
42
47
43
const compiler1 = webpack ( {
48
44
...webpackConfig ,
49
45
mode : 'development' ,
50
46
context : directoryForCase ,
51
47
cache : false ,
48
+ output : {
49
+ path : outputPath ,
50
+ } ,
52
51
} ) ;
53
52
54
53
await new Promise ( ( resolve , reject ) => {
@@ -59,6 +58,7 @@ describe('TestCache', () => {
59
58
return ;
60
59
}
61
60
61
+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 2 ) ;
62
62
expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
63
63
expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
64
64
@@ -73,6 +73,9 @@ describe('TestCache', () => {
73
73
mode : 'development' ,
74
74
context : directoryForCase ,
75
75
cache : false ,
76
+ output : {
77
+ path : outputPath ,
78
+ } ,
76
79
} ) ;
77
80
78
81
await new Promise ( ( resolve , reject ) => {
@@ -83,6 +86,8 @@ describe('TestCache', () => {
83
86
return ;
84
87
}
85
88
89
+ // Because webpack compare the source content before emitting
90
+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 0 ) ;
86
91
expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
87
92
expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
88
93
@@ -120,6 +125,9 @@ describe('TestCache', () => {
120
125
directoryForCase ,
121
126
'webpack.config.js'
122
127
) ) ;
128
+ const outputPath = path . resolve ( __dirname , 'js/cache-memory' ) ;
129
+
130
+ await del ( [ outputPath ] ) ;
123
131
124
132
const compiler1 = webpack ( {
125
133
...webpackConfig ,
@@ -128,6 +136,9 @@ describe('TestCache', () => {
128
136
cache : {
129
137
type : 'memory' ,
130
138
} ,
139
+ output : {
140
+ path : outputPath ,
141
+ } ,
131
142
} ) ;
132
143
133
144
await new Promise ( ( resolve , reject ) => {
@@ -138,6 +149,7 @@ describe('TestCache', () => {
138
149
return ;
139
150
}
140
151
152
+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 2 ) ;
141
153
expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
142
154
expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
143
155
@@ -154,6 +166,9 @@ describe('TestCache', () => {
154
166
cache : {
155
167
type : 'memory' ,
156
168
} ,
169
+ output : {
170
+ path : outputPath ,
171
+ } ,
157
172
} ) ;
158
173
159
174
await new Promise ( ( resolve , reject ) => {
@@ -164,6 +179,7 @@ describe('TestCache', () => {
164
179
return ;
165
180
}
166
181
182
+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 0 ) ;
167
183
expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
168
184
expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
169
185
@@ -201,6 +217,13 @@ describe('TestCache', () => {
201
217
directoryForCase ,
202
218
'webpack.config.js'
203
219
) ) ;
220
+ const outputPath = path . resolve ( __dirname , 'js/cache-filesystem' ) ;
221
+ const fileSystemCacheDirectory = path . resolve (
222
+ __dirname ,
223
+ './js/.cache/type-filesystem'
224
+ ) ;
225
+
226
+ await del ( [ outputPath , fileSystemCacheDirectory ] ) ;
204
227
205
228
const compiler1 = webpack ( {
206
229
...webpackConfig ,
@@ -212,6 +235,9 @@ describe('TestCache', () => {
212
235
idleTimeout : 0 ,
213
236
idleTimeoutForInitialStore : 0 ,
214
237
} ,
238
+ output : {
239
+ path : outputPath ,
240
+ } ,
215
241
} ) ;
216
242
217
243
await new Promise ( ( resolve , reject ) => {
@@ -222,6 +248,7 @@ describe('TestCache', () => {
222
248
return ;
223
249
}
224
250
251
+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 2 ) ;
225
252
expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
226
253
expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
227
254
@@ -241,6 +268,9 @@ describe('TestCache', () => {
241
268
idleTimeout : 0 ,
242
269
idleTimeoutForInitialStore : 0 ,
243
270
} ,
271
+ output : {
272
+ path : outputPath ,
273
+ } ,
244
274
} ) ;
245
275
246
276
await new Promise ( ( resolve , reject ) => {
@@ -251,6 +281,7 @@ describe('TestCache', () => {
251
281
return ;
252
282
}
253
283
284
+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 0 ) ;
254
285
expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
255
286
expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
256
287
0 commit comments