Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: environment option in vitest-pool-workers does not pick-up .dev.vars.{environment} #5641

Closed
gourgouris opened this issue Apr 17, 2024 · 0 comments · Fixed by #6180 or #6153
Closed
Labels
bug Something that isn't working

Comments

@gourgouris
Copy link

gourgouris commented Apr 17, 2024

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 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

@gourgouris gourgouris added the bug Something that isn't working label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Archived in project
1 participant