@@ -16,6 +16,7 @@ import type {
1616 Hyperdrive ,
1717 ImagesBinding ,
1818 KVNamespace ,
19+ Workflow ,
1920} from "@cloudflare/workers-types" ;
2021import type { Unstable_DevWorker } from "wrangler" ;
2122
@@ -31,16 +32,21 @@ type Env = {
3132 MY_HYPERDRIVE : Hyperdrive ;
3233 ASSETS : Fetcher ;
3334 IMAGES : ImagesBinding ;
35+ MY_WORKFLOW_INTERNAL : Workflow ;
36+ MY_WORKFLOW_EXTERNAL : Workflow ;
3437} ;
3538
3639const wranglerConfigFilePath = path . join ( __dirname , ".." , "wrangler.jsonc" ) ;
3740
3841describe ( "getPlatformProxy - env" , ( ) => {
3942 let devWorkers : Unstable_DevWorker [ ] ;
43+ let warn = { } as MockInstance < typeof console . warn > ;
4044
4145 beforeEach ( ( ) => {
4246 // Hide stdout messages from the test logs
4347 vi . spyOn ( console , "log" ) . mockImplementation ( ( ) => { } ) ;
48+ vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } ) ;
49+ warn = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
4450 } ) ;
4551
4652 describe ( "var bindings" , ( ) => {
@@ -261,41 +267,20 @@ describe("getPlatformProxy - env", () => {
261267 } ) ;
262268
263269 describe ( "DO warnings" , ( ) => {
264- let warn = { } as MockInstance < typeof console . warn > ;
265- beforeEach ( ( ) => {
266- warn = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
267- } ) ;
268- afterEach ( ( ) => {
269- warn . mockRestore ( ) ;
270- } ) ;
271-
272270 it ( "warns about internal DOs and doesn't crash" , async ( ) => {
273271 await getPlatformProxy < Env > ( {
274272 configPath : path . join ( __dirname , ".." , "wrangler_internal_do.jsonc" ) ,
275273 } ) ;
276- expect ( warn ) . toMatchInlineSnapshot ( `
277- [MockFunction warn] {
278- "calls": [
279- [
280- "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m You have defined bindings to the following internal Durable Objects:[0m
281-
282- - {"class_name":"MyDurableObject","name":"MY_DURABLE_OBJECT"}
283- These will not work in local development, but they should work in production.
284-
285- If you want to develop these locally, you can define your DO in a separate Worker, with a separate configuration file.
286- For detailed instructions, refer to the Durable Objects section here: [4mhttps://developers.cloudflare.com/workers/wrangler/api#supported-bindings[0m
287-
288- ",
289- ],
290- ],
291- "results": [
292- {
293- "type": "return",
294- "value": undefined,
295- },
296- ],
297- }
298- ` ) ;
274+ expect ( warn . mock . calls [ 0 ] [ 0 ] . replaceAll ( / [ \r \n ] + / g, "\n" ) )
275+ . toMatchInlineSnapshot ( `
276+ "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m You have defined bindings to the following internal Durable Objects:[0m
277+ - {"class_name":"MyDurableObject","name":"MY_DURABLE_OBJECT"}
278+ These will not work in local development, but they should work in production.
279+
280+ If you want to develop these locally, you can define your DO in a separate Worker, with a separate configuration file.
281+ For detailed instructions, refer to the Durable Objects section here: [4mhttps://developers.cloudflare.com/workers/wrangler/api#supported-bindings[0m
282+ "
283+ ` ) ;
299284 } ) ;
300285
301286 it ( "doesn't warn about external DOs and doesn't crash" , async ( ) => {
@@ -304,6 +289,20 @@ describe("getPlatformProxy - env", () => {
304289 } ) ;
305290 expect ( warn ) . not . toHaveBeenCalled ( ) ;
306291 } ) ;
292+
293+ it ( "warns about Workflows and doesn't crash" , async ( ) => {
294+ await getPlatformProxy < Env > ( {
295+ configPath : path . join ( __dirname , ".." , "wrangler_workflow.jsonc" ) ,
296+ } ) ;
297+ expect ( warn . mock . calls [ 0 ] [ 0 ] . replaceAll ( / [ \r \n ] + / g, "\n" ) )
298+ . toMatchInlineSnapshot ( `
299+ "[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m You have defined bindings to the following Workflows:[0m
300+ - {"binding":"MY_WORKFLOW_INTERNAL","name":"my-workflow-internal","class_name":"MyWorkflowInternal"}
301+ - {"binding":"MY_WORKFLOW_EXTERNAL","name":"my-workflow-external","class_name":"MyWorkflowExternal","script_name":"OtherWorker"}
302+ These are not available in local development, so you will not be able to bind to them when testing locally, but they should work in production.
303+ "
304+ ` ) ;
305+ } ) ;
307306 } ) ;
308307
309308 describe ( "with a target environment" , ( ) => {
0 commit comments