@@ -5353,6 +5353,14 @@ addEventListener('fetch', event => {});`
5353
5353
} ) ;
5354
5354
5355
5355
describe ( "workers_dev setting" , ( ) => {
5356
+ beforeEach ( ( ) => {
5357
+ vi . useFakeTimers ( ) ;
5358
+ } ) ;
5359
+
5360
+ afterEach ( ( ) => {
5361
+ vi . useRealTimers ( ) ;
5362
+ } ) ;
5363
+
5356
5364
it ( "should deploy to a workers.dev domain if workers_dev is undefined" , async ( ) => {
5357
5365
writeWranglerConfig ( ) ;
5358
5366
writeWorkerSource ( ) ;
@@ -5788,26 +5796,20 @@ addEventListener('fetch', event => {});`
5788
5796
` ) ;
5789
5797
} ) ;
5790
5798
5791
- it ( "should error if a compatibility_date is missing and suggest the correct month" , async ( ) => {
5792
- vi . spyOn ( Date . prototype , "getMonth" ) . mockImplementation ( ( ) => 11 ) ;
5793
- vi . spyOn ( Date . prototype , "getFullYear" ) . mockImplementation ( ( ) => 2020 ) ;
5794
- vi . spyOn ( Date . prototype , "getDate" ) . mockImplementation ( ( ) => 1 ) ;
5799
+ it ( "should error if a compatibility_date is missing and suggest the correct date" , async ( ) => {
5800
+ vi . setSystemTime ( new Date ( 2020 , 11 , 1 ) ) ;
5795
5801
5796
5802
writeWorkerSource ( ) ;
5797
- let err : undefined | Error ;
5798
- try {
5799
- await runWrangler ( "deploy ./index.js --name my-worker" ) ;
5800
- } catch ( e ) {
5801
- err = e as Error ;
5802
- }
5803
5803
5804
- expect ( err ?. message ) . toMatchInlineSnapshot ( `
5805
- "A compatibility_date is required when publishing. Add the following to your Wrangler configuration file:
5804
+ await expect (
5805
+ async ( ) => await runWrangler ( "deploy ./index.js --name my-worker" )
5806
+ ) . rejects . toThrowErrorMatchingInlineSnapshot ( `
5807
+ [Error: A compatibility_date is required when publishing. Add the following to your Wrangler configuration file:
5806
5808
\`\`\`
5807
- {\\ "compatibility_date\\":\\ "2020-12-01\\ "}
5809
+ {"compatibility_date": "2020-12-01"}
5808
5810
\`\`\`
5809
5811
Or you could pass it in your terminal as \`--compatibility-date 2020-12-01\`
5810
- See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information."
5812
+ See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.]
5811
5813
` ) ;
5812
5814
} ) ;
5813
5815
0 commit comments