@@ -224,19 +224,27 @@ const checkAssets = async (testCases: AssetTestCase[], deployedUrl: string) => {
224
224
const url = r . url ;
225
225
226
226
if ( testCase . content ) {
227
- expect ( text ) . toContain ( testCase . content ) ;
227
+ expect (
228
+ text ,
229
+ `expected content for ${ testCase . path } to be ${ testCase . content } `
230
+ ) . toContain ( testCase . content ) ;
228
231
}
229
232
if ( testCase . redirect ) {
230
- expect ( new URL ( url ) . pathname ) . toEqual (
231
- new URL ( testCase . redirect , deployedUrl ) . pathname
232
- ) ;
233
+ expect (
234
+ new URL ( url ) . pathname ,
235
+ `expected redirect for ${ testCase . path } to be ${ testCase . redirect } `
236
+ ) . toEqual ( new URL ( testCase . redirect , deployedUrl ) . pathname ) ;
233
237
} else {
234
- expect ( new URL ( url ) . pathname ) . toEqual (
235
- new URL ( testCase . path , deployedUrl ) . pathname
236
- ) ;
238
+ expect (
239
+ new URL ( url ) . pathname ,
240
+ `unexpected pathname for ${ testCase . path } `
241
+ ) . toEqual ( new URL ( testCase . path , deployedUrl ) . pathname ) ;
237
242
}
238
243
} ,
239
- { interval : 1_000 , timeout : 40_000 }
244
+ {
245
+ interval : 1_000 ,
246
+ timeout : 40_000 ,
247
+ }
240
248
) ;
241
249
}
242
250
} ;
@@ -570,7 +578,7 @@ Current Version ID: 00000000-0000-0000-0000-000000000000`);
570
578
await checkAssets ( testCases , deployedUrl ) ;
571
579
} ) ;
572
580
573
- it ( "runs the user Worker ahead of matching assets for matching run_worker_first routes" , async ( ) => {
581
+ it . only ( "runs the user Worker ahead of matching assets for matching run_worker_first routes" , async ( ) => {
574
582
await helper . seed ( {
575
583
"wrangler.toml" : dedent `
576
584
name = "${ workerName } "
@@ -581,7 +589,7 @@ Current Version ID: 00000000-0000-0000-0000-000000000000`);
581
589
binding = "ASSETS"
582
590
html_handling = "none"
583
591
not_found_handling = "404-page"
584
- run_worker_first = ["api/*", "!api/assets/*"]
592
+ run_worker_first = ["/ api/*", "!/ api/assets/*"]
585
593
` ,
586
594
"src/index.ts" : dedent `
587
595
export default {
@@ -598,7 +606,28 @@ Current Version ID: 00000000-0000-0000-0000-000000000000`);
598
606
const output = await helper . run ( `wrangler deploy` ) ;
599
607
const normalizedStdout = normalize ( output . stdout ) ;
600
608
601
- expect ( normalizedStdout ) . toMatchInlineSnapshot ( `""` ) ;
609
+ expect ( normalizedStdout ) . toContain ( dedent `
610
+ 🌀 Building list of assets...
611
+ ✨ Read 7 files from the assets directory /tmpdir
612
+ 🌀 Starting asset upload...
613
+ 🌀 Found 5 new or modified static assets to upload. Proceeding with upload...
614
+ + /404.html
615
+ + /api/index.html
616
+ + /index.html
617
+ + /api/assets/test.html
618
+ + /[boop].html
619
+ ` ) ;
620
+ expect ( normalizedStdout ) . toContain ( dedent `
621
+ ✨ Success! Uploaded 5 files (TIMINGS)
622
+ Total Upload: xx KiB / gzip: xx KiB
623
+ Your Worker has access to the following bindings:
624
+ Binding Resource
625
+ env.ASSETS Assets
626
+ Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
627
+ Deployed tmp-e2e-worker-00000000-0000-0000-0000-000000000000 triggers (TIMINGS)
628
+ https://tmp-e2e-worker-00000000-0000-0000-0000-000000000000.SUBDOMAIN.workers.dev
629
+ Current Version ID: 00000000-0000-0000-0000-000000000000
630
+ ` ) ;
602
631
603
632
const match = output . stdout . match (
604
633
/ (?< url > h t t p s : \/ \/ t m p - e 2 e - .+ ?\. .+ ?\. w o r k e r s \. d e v ) /
@@ -607,38 +636,14 @@ Current Version ID: 00000000-0000-0000-0000-000000000000`);
607
636
deployedUrl = match . groups . url ;
608
637
609
638
const testCases : AssetTestCase [ ] = [
610
- {
611
- path : "/index.html" ,
612
- content : "<h1>index.html</h1>" ,
613
- redirect : "/" ,
614
- } ,
615
- {
616
- path : "/[boop]" ,
617
- content : "<h1>[boop].html</h1>" ,
618
- redirect : "/%5Bboop%5D" ,
619
- } ,
620
- {
621
- path : "/missing.html" ,
622
- content : "<h1>404.html</h1>" ,
623
- redirect : "/" ,
624
- } ,
625
- {
626
- path : "/api" ,
627
- content : "Hello World from User Worker!" ,
628
- } ,
629
- {
630
- path : "/api/foo.html" ,
631
- content : "Hello World from User Worker!" ,
632
- } ,
633
- {
634
- path : "/api/assets" ,
635
- content : "404.html" ,
636
- } ,
637
- {
638
- path : "/api/assets/test.html" ,
639
- content : "api/assets/test.html" ,
640
- } ,
639
+ { path : "/index.html" , content : "<h1>index.html</h1>" } ,
640
+ { path : "/missing.html" , content : "<h1>404.html</h1>" } ,
641
+ { path : "/api/" , content : "Hello World from User Worker!" } ,
642
+ { path : "/api/foo.html" , content : "Hello World from User Worker!" } ,
643
+ { path : "/api/assets/missing" , content : "404.html" } ,
644
+ { path : "/api/assets/test.html" , content : "api/assets/test.html" } ,
641
645
] ;
646
+
642
647
await checkAssets ( testCases , deployedUrl ) ;
643
648
} ) ;
644
649
} ) ;
0 commit comments