@@ -30,6 +30,15 @@ const { protocolVersion } = packageJson;
3030
3131disableHttp2 ( ) ;
3232
33+ // Helper to create worker with standard options
34+ const createWorker = ( options : Parameters < typeof worker > [ 0 ] = { } ) =>
35+ worker ( {
36+ bundlePath : bundlePathForTest ( ) ,
37+ supportModules : true ,
38+ stubTimers : false ,
39+ ...options ,
40+ } ) ;
41+
3342describe ( 'worker' , ( ) => {
3443 beforeEach ( async ( ) => {
3544 await resetForTest ( testName ) ;
@@ -40,9 +49,7 @@ describe('worker', () => {
4049 } ) ;
4150
4251 test ( 'POST /bundles/:bundleTimestamp/render/:renderRequestDigest when bundle is provided and did not yet exist' , async ( ) => {
43- const app = worker ( {
44- bundlePath : bundlePathForTest ( ) ,
45- } ) ;
52+ const app = createWorker ( ) ;
4653
4754 const form = formAutoContent ( {
4855 gemVersion,
@@ -67,9 +74,7 @@ describe('worker', () => {
6774 } ) ;
6875
6976 test ( 'POST /bundles/:bundleTimestamp/render/:renderRequestDigest' , async ( ) => {
70- const app = worker ( {
71- bundlePath : bundlePathForTest ( ) ,
72- } ) ;
77+ const app = createWorker ( ) ;
7378
7479 const form = formAutoContent ( {
7580 gemVersion,
@@ -102,8 +107,7 @@ describe('worker', () => {
102107 async ( ) => {
103108 await createVmBundleForTest ( ) ;
104109
105- const app = worker ( {
106- bundlePath : bundlePathForTest ( ) ,
110+ const app = createWorker ( {
107111 password : 'password' ,
108112 } ) ;
109113
@@ -128,8 +132,7 @@ describe('worker', () => {
128132 async ( ) => {
129133 await createVmBundleForTest ( ) ;
130134
131- const app = worker ( {
132- bundlePath : bundlePathForTest ( ) ,
135+ const app = createWorker ( {
133136 password : 'password' ,
134137 } ) ;
135138
@@ -154,8 +157,7 @@ describe('worker', () => {
154157 async ( ) => {
155158 await createVmBundleForTest ( ) ;
156159
157- const app = worker ( {
158- bundlePath : bundlePathForTest ( ) ,
160+ const app = createWorker ( {
159161 password : 'my_password' ,
160162 } ) ;
161163
@@ -181,9 +183,7 @@ describe('worker', () => {
181183 async ( ) => {
182184 await createVmBundleForTest ( ) ;
183185
184- const app = worker ( {
185- bundlePath : bundlePathForTest ( ) ,
186- } ) ;
186+ const app = createWorker ( ) ;
187187
188188 const res = await app
189189 . inject ( )
@@ -204,8 +204,7 @@ describe('worker', () => {
204204 const bundleHash = 'some-bundle-hash' ;
205205 await createAsset ( testName , bundleHash ) ;
206206
207- const app = worker ( {
208- bundlePath : bundlePathForTest ( ) ,
207+ const app = createWorker ( {
209208 password : 'my_password' ,
210209 } ) ;
211210
@@ -230,8 +229,7 @@ describe('worker', () => {
230229 const bundleHash = 'some-bundle-hash' ;
231230 await createAsset ( testName , bundleHash ) ;
232231
233- const app = worker ( {
234- bundlePath : bundlePathForTest ( ) ,
232+ const app = createWorker ( {
235233 password : 'my_password' ,
236234 } ) ;
237235
@@ -254,8 +252,7 @@ describe('worker', () => {
254252
255253 test ( 'post /asset-exists requires targetBundles (protocol version 2.0.0)' , async ( ) => {
256254 await createAsset ( testName , String ( BUNDLE_TIMESTAMP ) ) ;
257- const app = worker ( {
258- bundlePath : bundlePathForTest ( ) ,
255+ const app = createWorker ( {
259256 password : 'my_password' ,
260257 } ) ;
261258
@@ -276,8 +273,7 @@ describe('worker', () => {
276273 test ( 'post /upload-assets' , async ( ) => {
277274 const bundleHash = 'some-bundle-hash' ;
278275
279- const app = worker ( {
280- bundlePath : bundlePathForTest ( ) ,
276+ const app = createWorker ( {
281277 password : 'my_password' ,
282278 } ) ;
283279
@@ -299,8 +295,7 @@ describe('worker', () => {
299295 const bundleHash = 'some-bundle-hash' ;
300296 const bundleHashOther = 'some-other-bundle-hash' ;
301297
302- const app = worker ( {
303- bundlePath : bundlePathForTest ( ) ,
298+ const app = createWorker ( {
304299 password : 'my_password' ,
305300 } ) ;
306301
@@ -325,8 +320,7 @@ describe('worker', () => {
325320 const bundleHash = 'some-bundle-hash' ;
326321 const secondaryBundleHash = 'secondary-bundle-hash' ;
327322
328- const app = worker ( {
329- bundlePath : bundlePathForTest ( ) ,
323+ const app = createWorker ( {
330324 password : 'my_password' ,
331325 } ) ;
332326
@@ -380,8 +374,7 @@ describe('worker', () => {
380374 test ( 'post /upload-assets with only bundles (no assets)' , async ( ) => {
381375 const bundleHash = 'bundle-only-hash' ;
382376
383- const app = worker ( {
384- bundlePath : bundlePathForTest ( ) ,
377+ const app = createWorker ( {
385378 password : 'my_password' ,
386379 } ) ;
387380
@@ -416,8 +409,7 @@ describe('worker', () => {
416409 test ( 'post /upload-assets with no assets and no bundles (empty request)' , async ( ) => {
417410 const bundleHash = 'empty-request-hash' ;
418411
419- const app = worker ( {
420- bundlePath : bundlePathForTest ( ) ,
412+ const app = createWorker ( {
421413 password : 'my_password' ,
422414 } ) ;
423415
@@ -444,8 +436,7 @@ describe('worker', () => {
444436 test ( 'post /upload-assets with duplicate bundle hash silently skips overwrite and returns 200' , async ( ) => {
445437 const bundleHash = 'duplicate-bundle-hash' ;
446438
447- const app = worker ( {
448- bundlePath : bundlePathForTest ( ) ,
439+ const app = createWorker ( {
449440 password : 'my_password' ,
450441 } ) ;
451442
@@ -520,16 +511,15 @@ describe('worker', () => {
520511 expect ( files ) . toHaveLength ( 1 ) ;
521512 expect ( files [ 0 ] ) . toBe ( `${ bundleHash } .js` ) ;
522513
523- // Verify the original content is preserved (62 bytes from bundle.js, not 84 from secondary-bundle.js)
524- expect ( secondBundleSize ) . toBe ( 62 ) ; // Size of getFixtureBundle(), not getFixtureSecondaryBundle()
514+ // Verify the original content is preserved (1646 bytes from bundle.js, not 1689 from secondary-bundle.js)
515+ expect ( secondBundleSize ) . toBe ( 1646 ) ; // Size of getFixtureBundle(), not getFixtureSecondaryBundle()
525516 } ) ;
526517
527518 test ( 'post /upload-assets with bundles placed in their own hash directories, not targetBundles directories' , async ( ) => {
528519 const bundleHash = 'actual-bundle-hash' ;
529520 const targetBundleHash = 'target-bundle-hash' ; // Different from actual bundle hash
530521
531- const app = worker ( {
532- bundlePath : bundlePathForTest ( ) ,
522+ const app = createWorker ( {
533523 password : 'my_password' ,
534524 } ) ;
535525
@@ -574,8 +564,7 @@ describe('worker', () => {
574564 describe ( 'incremental render endpoint' , ( ) => {
575565 // Helper functions to reduce code duplication
576566 const createWorkerApp = ( password = 'my_password' ) =>
577- worker ( {
578- bundlePath : bundlePathForTest ( ) ,
567+ createWorker ( {
579568 password,
580569 } ) ;
581570
0 commit comments