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

Support for define global constants from vite.config #706

Closed
4 tasks done
timleers opened this issue Feb 8, 2022 · 3 comments · Fixed by #743
Closed
4 tasks done

Support for define global constants from vite.config #706

timleers opened this issue Feb 8, 2022 · 3 comments · Fixed by #743

Comments

@timleers
Copy link

timleers commented Feb 8, 2022

Clear and concise description of the problem

In our webapp we are using vite's define for global constants. Unfortunately our tests using these constants are failing because the variables are not defined. Seems like vitest is ignoring everything included in the define context of the vite.config.js.

Do you plan to support that or did i miss something and its already working?

Suggested solution

Parse 'define' part of the vite.config and provide items as constants.

Alternative

Not use define in vite.config

Additional context

if there is anything i can do to support this awesome project please let me know. I'm happy to contribute

Validations

@stygian-desolator
Copy link
Contributor

Could you please provide a reproduce demo ? I tried it and everything was fine.
https://stackblitz.com/edit/vitest-dev-vitest-b31hwg?file=vite.config.ts

@timleers
Copy link
Author

timleers commented Feb 9, 2022

Seems like the issue occurs only when using the constant within a vue component:
https://stackblitz.com/edit/vitejs-vite-w5twrd?file=src/components/HelloWorld.test.ts

@antfu antfu added the bug label Feb 10, 2022
@stygian-desolator
Copy link
Contributor

Seems like the issue occurs only when using the constant within a vue component: https://stackblitz.com/edit/vitejs-vite-w5twrd?file=src/components/HelloWorld.test.ts

I'm trying to solve this problem.
If you're desperate for a solution, try this
https://stackblitz.com/edit/vitejs-vite-y6gi6x?file=src%2Fcomponents%2FHelloWorld.vue

@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants