@@ -94,3 +94,62 @@ test('Should return a vite error page with stack trace - /invalid-error-response
9494 expect ( response ?. status ( ) ) . toBe ( 500 )
9595 expect ( await response ?. text ( ) ) . toContain ( 'e2e/mock/worker.ts' )
9696} )
97+
98+ test ( 'Should set bindings from wrangler.toml [vars]' , async ( { page } ) => {
99+ const res = await page . goto ( '/env' , { waitUntil : 'domcontentloaded' } )
100+ expect ( res ?. ok ( ) ) . toBe ( true )
101+ const json = await res ?. json ( )
102+ expect ( json ) . toBeTruthy ( )
103+ expect ( json . env ) . toHaveProperty (
104+ 'VARIABLE_FROM_WRANGLER_TOML' ,
105+ 'VARIABLE_FROM_WRANGLER_TOML_VALUE'
106+ )
107+ } )
108+
109+ test ( 'Should set bindings from wrangler.toml [[d1_database]]' , async ( { page } ) => {
110+ const res = await page . goto ( '/env' , { waitUntil : 'domcontentloaded' } )
111+ expect ( res ?. ok ( ) ) . toBe ( true )
112+ const json = await res ?. json ( )
113+ expect ( json ) . toBeTruthy ( )
114+ expect ( json . env ) . toHaveProperty ( 'DB_FROM_WRANGLER_TOML' )
115+ } )
116+
117+ test ( 'Should set bindings from root `env` in config' , async ( { page } ) => {
118+ const res = await page . goto ( '/env' , { waitUntil : 'domcontentloaded' } )
119+ expect ( res ?. ok ( ) ) . toBe ( true )
120+ const json = await res ?. json ( )
121+ expect ( json ) . toBeTruthy ( )
122+ expect ( json . env ) . toHaveProperty ( 'ENV_FROM_ROOT' , 'ENV_FROM_ROOT_VALUE' )
123+ } )
124+
125+ test ( 'Should set bindings from `cf` in config' , async ( { page } ) => {
126+ const res = await page . goto ( '/env' , { waitUntil : 'domcontentloaded' } )
127+ expect ( res ?. ok ( ) ) . toBe ( true )
128+ const json = await res ?. json ( )
129+ expect ( json ) . toBeTruthy ( )
130+ expect ( json . env ) . toHaveProperty ( 'ENV_FROM_DEPRACATED_CF' , 'ENV_FROM_DEPRACATED_CF_VALUE' )
131+ } )
132+
133+ test ( 'Should set bindings from `plugins` in config' , async ( { page } ) => {
134+ const res = await page . goto ( '/env' , { waitUntil : 'domcontentloaded' } )
135+ expect ( res ?. ok ( ) ) . toBe ( true )
136+ const json = await res ?. json ( )
137+ expect ( json ) . toBeTruthy ( )
138+ expect ( json . env ) . toHaveProperty ( 'ENV_FROM_PLUGIN' , 'ENV_FROM_PLUGIN_VALUE' )
139+ } )
140+
141+ test ( 'Should set bindings from `plugins` in config (async)' , async ( { page } ) => {
142+ const res = await page . goto ( '/env' , { waitUntil : 'domcontentloaded' } )
143+ expect ( res ?. ok ( ) ) . toBe ( true )
144+ const json = await res ?. json ( )
145+ expect ( json ) . toBeTruthy ( )
146+ expect ( json . env ) . toHaveProperty ( 'ENV_FROM_PLUGIN_AS_FUNC' , 'ENV_FROM_PLUGIN_AS_FUNC_VALUE' )
147+ } )
148+
149+ test ( 'Should set bindings from `adapter` in config' , async ( { page } ) => {
150+ const res = await page . goto ( '/env' , { waitUntil : 'domcontentloaded' } )
151+ expect ( res ?. ok ( ) ) . toBe ( true )
152+ const json = await res ?. json ( )
153+ expect ( json ) . toBeTruthy ( )
154+ expect ( json . env ) . toHaveProperty ( 'ENV_FROM_ADAPTER' , 'ENV_FROM_ADAPTER_VALUE' )
155+ } )
0 commit comments