@@ -7,13 +7,6 @@ import path from 'path';
77import webpack from 'webpack' ;
88import del from 'del' ;
99
10- const fileSystemCacheDirectory = path . resolve (
11- __dirname ,
12- './outputs/cache/type-filesystem'
13- ) ;
14-
15- del . sync ( fileSystemCacheDirectory ) ;
16-
1710describe ( 'TestCache' , ( ) => {
1811 afterEach ( ( ) => {
1912 jest . clearAllMocks ( ) ;
@@ -43,12 +36,18 @@ describe('TestCache', () => {
4336 directoryForCase ,
4437 'webpack.config.js'
4538 ) ) ;
39+ const outputPath = path . resolve ( __dirname , 'js/cache-false' ) ;
40+
41+ await del ( [ outputPath ] ) ;
4642
4743 const compiler1 = webpack ( {
4844 ...webpackConfig ,
4945 mode : 'development' ,
5046 context : directoryForCase ,
5147 cache : false ,
48+ output : {
49+ path : outputPath ,
50+ } ,
5251 } ) ;
5352
5453 await new Promise ( ( resolve , reject ) => {
@@ -59,6 +58,7 @@ describe('TestCache', () => {
5958 return ;
6059 }
6160
61+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 2 ) ;
6262 expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
6363 expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
6464
@@ -73,6 +73,9 @@ describe('TestCache', () => {
7373 mode : 'development' ,
7474 context : directoryForCase ,
7575 cache : false ,
76+ output : {
77+ path : outputPath ,
78+ } ,
7679 } ) ;
7780
7881 await new Promise ( ( resolve , reject ) => {
@@ -83,6 +86,8 @@ describe('TestCache', () => {
8386 return ;
8487 }
8588
89+ // Because webpack compare the source content before emitting
90+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 0 ) ;
8691 expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
8792 expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
8893
@@ -120,6 +125,9 @@ describe('TestCache', () => {
120125 directoryForCase ,
121126 'webpack.config.js'
122127 ) ) ;
128+ const outputPath = path . resolve ( __dirname , 'js/cache-memory' ) ;
129+
130+ await del ( [ outputPath ] ) ;
123131
124132 const compiler1 = webpack ( {
125133 ...webpackConfig ,
@@ -128,6 +136,9 @@ describe('TestCache', () => {
128136 cache : {
129137 type : 'memory' ,
130138 } ,
139+ output : {
140+ path : outputPath ,
141+ } ,
131142 } ) ;
132143
133144 await new Promise ( ( resolve , reject ) => {
@@ -138,6 +149,7 @@ describe('TestCache', () => {
138149 return ;
139150 }
140151
152+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 2 ) ;
141153 expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
142154 expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
143155
@@ -154,6 +166,9 @@ describe('TestCache', () => {
154166 cache : {
155167 type : 'memory' ,
156168 } ,
169+ output : {
170+ path : outputPath ,
171+ } ,
157172 } ) ;
158173
159174 await new Promise ( ( resolve , reject ) => {
@@ -164,6 +179,7 @@ describe('TestCache', () => {
164179 return ;
165180 }
166181
182+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 0 ) ;
167183 expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
168184 expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
169185
@@ -201,6 +217,13 @@ describe('TestCache', () => {
201217 directoryForCase ,
202218 'webpack.config.js'
203219 ) ) ;
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 ] ) ;
204227
205228 const compiler1 = webpack ( {
206229 ...webpackConfig ,
@@ -212,6 +235,9 @@ describe('TestCache', () => {
212235 idleTimeout : 0 ,
213236 idleTimeoutForInitialStore : 0 ,
214237 } ,
238+ output : {
239+ path : outputPath ,
240+ } ,
215241 } ) ;
216242
217243 await new Promise ( ( resolve , reject ) => {
@@ -222,6 +248,7 @@ describe('TestCache', () => {
222248 return ;
223249 }
224250
251+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 2 ) ;
225252 expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
226253 expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
227254
@@ -241,6 +268,9 @@ describe('TestCache', () => {
241268 idleTimeout : 0 ,
242269 idleTimeoutForInitialStore : 0 ,
243270 } ,
271+ output : {
272+ path : outputPath ,
273+ } ,
244274 } ) ;
245275
246276 await new Promise ( ( resolve , reject ) => {
@@ -251,6 +281,7 @@ describe('TestCache', () => {
251281 return ;
252282 }
253283
284+ expect ( stats . compilation . emittedAssets . size ) . toBe ( 0 ) ;
254285 expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
255286 expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
256287
0 commit comments