You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the new option "environment" in poolOptions.workers.wrangler, when the worker boots-up, it says Using vars defined in src\.dev.vars regardless of the environment specified.
In contrast, when I pass --env to wrangler, the proper .dev.vars.{environment} is picked up
Expected behavior
Environment as a wrangler thing would be expected to behave the same way between wrangler dev and vitest
Steps to reproduce
Add a .dev.vars.tst besides .dev.vars and add a new line ENVIRONMENT=tst
In .dev.vars add a new line ENVIRONMENT=dev
(I think wrangler.toml's var section is not necessary)
write a worker that logs the value of that env variable.
in vitest.config.ts set poolOptions.workers.wrangler.environment = "tst"
running wrangler dev --env tst prints tst
running vitest prints dev
In the relevant PR #5612 I observe that in unstable_getMiniflareWorkerOptions environment is passed into readConfig but a few lines below env is initialized to undefined
and so getBindings thinks the env is undefined, which passes on to getVarsForDev which does not load the .dev.vars correctly.
Also, it could be that getBindings is maybe not picking-up the correct bindings per environment, which would have a higher impact than my issue.
I could be completely wrong though, appologies in advance.
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
No response
The text was updated successfully, but these errors were encountered:
Which Cloudflare product(s) does this pertain to?
Workers Vitest Integration
What version(s) of the tool(s) are you using?
wrangler: ^3.51.0, vitest: 1.3.0, @cloudflare/vitest-pool-workers: ^0.2.0
What version of Node are you using?
v18.18.2
What operating system and version are you using?
Win 11
Describe the Bug
Observed behavior
With the new option "environment" in poolOptions.workers.wrangler, when the worker boots-up, it says
Using vars defined in src\.dev.vars
regardless of the environment specified.In contrast, when I pass --env to wrangler, the proper
.dev.vars.{environment}
is picked upExpected behavior
Environment
as a wrangler thing would be expected to behave the same way betweenwrangler dev
andvitest
Steps to reproduce
Add a
.dev.vars.tst
besides.dev.vars
and add a new lineENVIRONMENT=tst
In
.dev.vars
add a new lineENVIRONMENT=dev
(I think wrangler.toml's
var
section is not necessary)write a worker that logs the value of that env variable.
in vitest.config.ts set
poolOptions.workers.wrangler.environment = "tst"
running
wrangler dev --env tst
printstst
running
vitest
printsdev
In the relevant PR #5612 I observe that in
unstable_getMiniflareWorkerOptions
environment is passed into readConfig but a few lines below env is initialized to undefinedand so getBindings thinks the env is undefined, which passes on to getVarsForDev which does not load the
.dev.vars
correctly.Also, it could be that getBindings is maybe not picking-up the correct bindings per environment, which would have a higher impact than my issue.
I could be completely wrong though, appologies in advance.
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
No response
The text was updated successfully, but these errors were encountered: