11import path from "path" ;
22import { D1Database , R2Bucket } from "@cloudflare/workers-types" ;
33import { toMatchImageSnapshot } from "jest-image-snapshot" ;
4- /* eslint-disable workers-sdk/no-vitest-import-expect -- uses expect throughout tests */
5- import {
6- afterEach ,
7- beforeEach ,
8- describe ,
9- expect ,
10- it ,
11- MockInstance ,
12- vi ,
13- } from "vitest" ;
14- /* eslint-enable workers-sdk/no-vitest-import-expect */
4+ import { beforeEach , describe , it , MockInstance , vi } from "vitest" ;
155import { getPlatformProxy } from "./shared" ;
166import type {
177 Fetcher ,
@@ -20,7 +10,6 @@ import type {
2010 KVNamespace ,
2111 Workflow ,
2212} from "@cloudflare/workers-types" ;
23- import type { Unstable_DevWorker } from "wrangler" ;
2413
2514type Env = {
2615 MY_VAR : string ;
@@ -41,7 +30,6 @@ type Env = {
4130const wranglerConfigFilePath = path . join ( __dirname , ".." , "wrangler.jsonc" ) ;
4231
4332describe ( "getPlatformProxy - env" , ( ) => {
44- let devWorkers : Unstable_DevWorker [ ] ;
4533 let warn = { } as MockInstance < typeof console . warn > ;
4634
4735 beforeEach ( ( ) => {
@@ -52,7 +40,9 @@ describe("getPlatformProxy - env", () => {
5240 } ) ;
5341
5442 describe ( "var bindings" , ( ) => {
55- it ( "correctly obtains var bindings from both wrangler config and .dev.vars" , async ( ) => {
43+ it ( "correctly obtains var bindings from both wrangler config and .dev.vars" , async ( {
44+ expect,
45+ } ) => {
5646 const { env, dispose } = await getPlatformProxy < Env > ( {
5747 configPath : wranglerConfigFilePath ,
5848 } ) ;
@@ -68,7 +58,9 @@ describe("getPlatformProxy - env", () => {
6858 }
6959 } ) ;
7060
71- it ( "correctly makes vars from .dev.vars override the ones in wrangler config" , async ( ) => {
61+ it ( "correctly makes vars from .dev.vars override the ones in wrangler config" , async ( {
62+ expect,
63+ } ) => {
7264 const { env, dispose } = await getPlatformProxy < Env > ( {
7365 configPath : wranglerConfigFilePath ,
7466 } ) ;
@@ -81,7 +73,9 @@ describe("getPlatformProxy - env", () => {
8173 }
8274 } ) ;
8375
84- it ( "correctly makes vars from .dev.vars not override bindings of the same name from wrangler config" , async ( ) => {
76+ it ( "correctly makes vars from .dev.vars not override bindings of the same name from wrangler config" , async ( {
77+ expect,
78+ } ) => {
8579 const { env, dispose } = await getPlatformProxy < Env > ( {
8680 configPath : wranglerConfigFilePath ,
8781 } ) ;
@@ -99,7 +93,9 @@ describe("getPlatformProxy - env", () => {
9993 }
10094 } ) ;
10195
102- it ( "correctly reads a toml from a custom path alongside with its .dev.vars" , async ( ) => {
96+ it ( "correctly reads a toml from a custom path alongside with its .dev.vars" , async ( {
97+ expect,
98+ } ) => {
10399 const { env, dispose } = await getPlatformProxy < Env > ( {
104100 configPath : path . join (
105101 __dirname ,
@@ -123,7 +119,7 @@ describe("getPlatformProxy - env", () => {
123119 } ) ;
124120 } ) ;
125121
126- it ( "correctly reads a json config file" , async ( ) => {
122+ it ( "correctly reads a json config file" , async ( { expect } ) => {
127123 const { env, dispose } = await getPlatformProxy < Env > ( {
128124 configPath : path . join ( __dirname , ".." , "wrangler.json" ) ,
129125 } ) ;
@@ -139,7 +135,7 @@ describe("getPlatformProxy - env", () => {
139135 }
140136 } ) ;
141137
142- it ( "correctly obtains functioning ASSETS bindings" , async ( ) => {
138+ it ( "correctly obtains functioning ASSETS bindings" , async ( { expect } ) => {
143139 const { env, dispose } = await getPlatformProxy < Env > ( {
144140 configPath : wranglerConfigFilePath ,
145141 } ) ;
@@ -149,7 +145,7 @@ describe("getPlatformProxy - env", () => {
149145 await dispose ( ) ;
150146 } ) ;
151147
152- it ( "correctly obtains functioning KV bindings" , async ( ) => {
148+ it ( "correctly obtains functioning KV bindings" , async ( { expect } ) => {
153149 const { env, dispose } = await getPlatformProxy < Env > ( {
154150 configPath : wranglerConfigFilePath ,
155151 } ) ;
@@ -164,7 +160,7 @@ describe("getPlatformProxy - env", () => {
164160 await dispose ( ) ;
165161 } ) ;
166162
167- it ( "correctly obtains functioning R2 bindings" , async ( ) => {
163+ it ( "correctly obtains functioning R2 bindings" , async ( { expect } ) => {
168164 const { env, dispose } = await getPlatformProxy < Env > ( {
169165 configPath : wranglerConfigFilePath ,
170166 } ) ;
@@ -182,7 +178,7 @@ describe("getPlatformProxy - env", () => {
182178 }
183179 } ) ;
184180
185- it ( "correctly obtains functioning D1 bindings" , async ( ) => {
181+ it ( "correctly obtains functioning D1 bindings" , async ( { expect } ) => {
186182 const { env, dispose } = await getPlatformProxy < Env > ( {
187183 configPath : wranglerConfigFilePath ,
188184 } ) ;
@@ -210,7 +206,7 @@ describe("getPlatformProxy - env", () => {
210206 }
211207 } ) ;
212208
213- it ( "correctly obtains functioning Image bindings" , async ( ) => {
209+ it ( "correctly obtains functioning Image bindings" , async ( { expect } ) => {
214210 expect . extend ( { toMatchImageSnapshot } ) ;
215211
216212 const { env, dispose } = await getPlatformProxy < Env > ( {
@@ -249,7 +245,9 @@ describe("getPlatformProxy - env", () => {
249245
250246 // Important: the hyperdrive values are passthrough ones since the workerd specific hyperdrive values only make sense inside
251247 // workerd itself and would simply not work in a node.js process
252- it ( "correctly obtains passthrough Hyperdrive bindings" , async ( ) => {
248+ it ( "correctly obtains passthrough Hyperdrive bindings" , async ( {
249+ expect,
250+ } ) => {
253251 const { env, dispose } = await getPlatformProxy < Env > ( {
254252 configPath : wranglerConfigFilePath ,
255253 } ) ;
@@ -269,7 +267,7 @@ describe("getPlatformProxy - env", () => {
269267 } ) ;
270268
271269 describe ( "DO warnings" , ( ) => {
272- it ( "warns about internal DOs and doesn't crash" , async ( ) => {
270+ it ( "warns about internal DOs and doesn't crash" , async ( { expect } ) => {
273271 await getPlatformProxy < Env > ( {
274272 configPath : path . join ( __dirname , ".." , "wrangler_internal_do.jsonc" ) ,
275273 } ) ;
@@ -285,14 +283,16 @@ describe("getPlatformProxy - env", () => {
285283 ` ) ;
286284 } ) ;
287285
288- it ( "doesn't warn about external DOs and doesn't crash" , async ( ) => {
286+ it ( "doesn't warn about external DOs and doesn't crash" , async ( {
287+ expect,
288+ } ) => {
289289 await getPlatformProxy < Env > ( {
290290 configPath : path . join ( __dirname , ".." , "wrangler_external_do.jsonc" ) ,
291291 } ) ;
292292 expect ( warn ) . not . toHaveBeenCalled ( ) ;
293293 } ) ;
294294
295- it ( "warns about Workflows and doesn't crash" , async ( ) => {
295+ it ( "warns about Workflows and doesn't crash" , async ( { expect } ) => {
296296 await getPlatformProxy < Env > ( {
297297 configPath : path . join ( __dirname , ".." , "wrangler_workflow.jsonc" ) ,
298298 } ) ;
@@ -308,7 +308,9 @@ describe("getPlatformProxy - env", () => {
308308 } ) ;
309309
310310 describe ( "with a target environment" , ( ) => {
311- it ( "should provide bindings targeting a specified environment and also inherit top-level ones" , async ( ) => {
311+ it ( "should provide bindings targeting a specified environment and also inherit top-level ones" , async ( {
312+ expect,
313+ } ) => {
312314 const { env, dispose } = await getPlatformProxy < Env > ( {
313315 configPath : wranglerConfigFilePath ,
314316 environment : "production" ,
@@ -325,7 +327,9 @@ describe("getPlatformProxy - env", () => {
325327 }
326328 } ) ;
327329
328- it ( "should not provide bindings targeting an environment when none was specified" , async ( ) => {
330+ it ( "should not provide bindings targeting an environment when none was specified" , async ( {
331+ expect,
332+ } ) => {
329333 const { env, dispose } = await getPlatformProxy < Env > ( {
330334 configPath : wranglerConfigFilePath ,
331335 } ) ;
@@ -341,7 +345,9 @@ describe("getPlatformProxy - env", () => {
341345 }
342346 } ) ;
343347
344- it ( "should provide secrets targeting a specified environment" , async ( ) => {
348+ it ( "should provide secrets targeting a specified environment" , async ( {
349+ expect,
350+ } ) => {
345351 const { env, dispose } = await getPlatformProxy < Env > ( {
346352 configPath : wranglerConfigFilePath ,
347353 environment : "production" ,
@@ -355,7 +361,9 @@ describe("getPlatformProxy - env", () => {
355361 }
356362 } ) ;
357363
358- it ( "should error if a non-existent environment is provided" , async ( ) => {
364+ it ( "should error if a non-existent environment is provided" , async ( {
365+ expect,
366+ } ) => {
359367 await expect (
360368 getPlatformProxy ( {
361369 configPath : wranglerConfigFilePath ,
0 commit comments