@@ -196,15 +196,12 @@ test.serial('#createServiceWorker()', async t => {
196196 plugin . configure ( compiler , compilation ) ;
197197 return callback ( ) ;
198198 } ) ;
199-
200199 await runCompiler ( compiler ) ;
201-
202200 t . truthy ( await plugin . createServiceWorker ( ) , 'generate something' ) ;
203201} ) ;
204202
205- test . serial ( '#writeServiceWorker(serviceWorker, compiler, callback )' , async t => {
203+ test . serial ( '#writeServiceWorker(serviceWorker, compiler)' , async t => {
206204 t . plan ( 2 ) ;
207-
208205 const filepath = path . resolve ( __dirname , 'tmp/service-worker.js' ) ;
209206 const compiler = webpack ( webpackConfig ( ) ) ;
210207 const plugin = new SWPrecacheWebpackPlugin ( { filepath} ) ;
@@ -215,10 +212,12 @@ test.serial('#writeServiceWorker(serviceWorker, compiler, callback)', async t =>
215212 plugin . apply ( compiler ) ;
216213
217214 compiler . plugin ( 'after-emit' , ( compilation , callback ) => {
218- plugin . writeServiceWorker ( serviceWorker , compiler , callback ) ;
215+ plugin . writeServiceWorker ( serviceWorker , compiler )
216+ . then ( ( ) => callback ( ) )
217+ . catch ( err => callback ( err ) ) ;
219218 } ) ;
220- await runCompiler ( compiler ) ;
221219
220+ await runCompiler ( compiler ) ;
222221 t . truthy ( await fsExists ( filepath ) , 'service-worker should exist' ) ;
223222
224223} ) ;
@@ -257,7 +256,7 @@ test.serial('importScripts[<index>] should support entry point & dynamically imp
257256 'some-script-path.js' ,
258257 { filename : 'some-script-path.[hash].js' } ,
259258 { chunkName : 'sw' } ,
260- { chunkName : 'service-worker-imported-script-2' }
259+ { chunkName : 'service-worker-imported-script-2' } ,
261260 ] ,
262261 } ) ;
263262
@@ -313,9 +312,11 @@ test.serial('should keep [hash] in importScripts after configuring SW', async t
313312 const plugin = new SWPrecacheWebpackPlugin ( { filepath, importScripts : [ 'some_sw-[hash].js' ] } ) ;
314313
315314 plugin . apply ( compiler ) ;
316- compiler . plugin ( 'after-emit' , ( compilation ) => {
315+ compiler . plugin ( 'after-emit' , ( compilation , callback ) => {
317316 plugin . configure ( compiler , compilation ) ;
317+ callback ( ) ;
318318 } ) ;
319+
319320 await runCompiler ( compiler ) ;
320321
321322 t . truthy ( plugin . options . importScripts [ 0 ] === 'some_sw-[hash].js' , 'hash should be preserve after writing the sw' ) ;
@@ -329,8 +330,9 @@ test.serial('should not modify importScripts value when no [hash] is provided',
329330 const plugin = new SWPrecacheWebpackPlugin ( { filepath, importScripts : [ 'some_script.js' ] } ) ;
330331
331332 plugin . apply ( compiler ) ;
332- compiler . plugin ( 'after-emit' , ( compilation ) => {
333+ compiler . plugin ( 'after-emit' , ( compilation , callback ) => {
333334 plugin . configure ( compiler , compilation ) ;
335+ callback ( ) ;
334336 } ) ;
335337 await runCompiler ( compiler ) ;
336338
0 commit comments