@@ -15,7 +15,135 @@ const fileSystemCacheDirectory = path.resolve(
1515del . sync ( fileSystemCacheDirectory ) ;
1616
1717describe ( 'TestCache' , ( ) => {
18- it ( 'should work' , async ( ) => {
18+ it ( 'should work without cache' , async ( ) => {
19+ if ( webpack . version [ 0 ] !== '4' ) {
20+ const casesDirectory = path . resolve ( __dirname , 'cases' ) ;
21+ const directoryForCase = path . resolve ( casesDirectory , 'simple' ) ;
22+ // eslint-disable-next-line import/no-dynamic-require, global-require
23+ const webpackConfig = require ( path . resolve (
24+ directoryForCase ,
25+ 'webpack.config.js'
26+ ) ) ;
27+
28+ const compiler1 = webpack ( {
29+ ...webpackConfig ,
30+ mode : 'development' ,
31+ context : directoryForCase ,
32+ cache : false ,
33+ } ) ;
34+
35+ await new Promise ( ( resolve , reject ) => {
36+ compiler1 . run ( ( error , stats ) => {
37+ if ( error ) {
38+ reject ( error ) ;
39+
40+ return ;
41+ }
42+
43+ expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
44+ expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
45+
46+ compiler1 . close ( ( ) => {
47+ resolve ( ) ;
48+ } ) ;
49+ } ) ;
50+ } ) ;
51+
52+ const compiler2 = webpack ( {
53+ ...webpackConfig ,
54+ mode : 'development' ,
55+ context : directoryForCase ,
56+ cache : false ,
57+ } ) ;
58+
59+ await new Promise ( ( resolve , reject ) => {
60+ compiler2 . run ( ( error , stats ) => {
61+ if ( error ) {
62+ reject ( error ) ;
63+
64+ return ;
65+ }
66+
67+ expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
68+ expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
69+
70+ compiler2 . close ( ( ) => {
71+ resolve ( ) ;
72+ } ) ;
73+ } ) ;
74+ } ) ;
75+ } else {
76+ expect ( true ) . toBe ( true ) ;
77+ }
78+ } ) ;
79+
80+ it ( 'should work with the "memory" cache' , async ( ) => {
81+ if ( webpack . version [ 0 ] !== '4' ) {
82+ const casesDirectory = path . resolve ( __dirname , 'cases' ) ;
83+ const directoryForCase = path . resolve ( casesDirectory , 'simple' ) ;
84+ // eslint-disable-next-line import/no-dynamic-require, global-require
85+ const webpackConfig = require ( path . resolve (
86+ directoryForCase ,
87+ 'webpack.config.js'
88+ ) ) ;
89+
90+ const compiler1 = webpack ( {
91+ ...webpackConfig ,
92+ mode : 'development' ,
93+ context : directoryForCase ,
94+ cache : {
95+ type : 'memory' ,
96+ } ,
97+ } ) ;
98+
99+ await new Promise ( ( resolve , reject ) => {
100+ compiler1 . run ( ( error , stats ) => {
101+ if ( error ) {
102+ reject ( error ) ;
103+
104+ return ;
105+ }
106+
107+ expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
108+ expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
109+
110+ compiler1 . close ( ( ) => {
111+ resolve ( ) ;
112+ } ) ;
113+ } ) ;
114+ } ) ;
115+
116+ const compiler2 = webpack ( {
117+ ...webpackConfig ,
118+ mode : 'development' ,
119+ context : directoryForCase ,
120+ cache : {
121+ type : 'memory' ,
122+ } ,
123+ } ) ;
124+
125+ await new Promise ( ( resolve , reject ) => {
126+ compiler2 . run ( ( error , stats ) => {
127+ if ( error ) {
128+ reject ( error ) ;
129+
130+ return ;
131+ }
132+
133+ expect ( stats . compilation . warnings ) . toHaveLength ( 0 ) ;
134+ expect ( stats . compilation . errors ) . toHaveLength ( 0 ) ;
135+
136+ compiler2 . close ( ( ) => {
137+ resolve ( ) ;
138+ } ) ;
139+ } ) ;
140+ } ) ;
141+ } else {
142+ expect ( true ) . toBe ( true ) ;
143+ }
144+ } ) ;
145+
146+ it ( 'should work with the "filesystem" cache' , async ( ) => {
19147 if ( webpack . version [ 0 ] !== '4' ) {
20148 const casesDirectory = path . resolve ( __dirname , 'cases' ) ;
21149 const directoryForCase = path . resolve ( casesDirectory , 'simple' ) ;
0 commit comments