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
The background is I'm trying to make the Nuxt apps work in @teambit.
I tried to run Vitest via Node APIs and have found the app doesn't render properly in the tests if the current working dir is not the root path of the project.
@Jinjiang Hello there! I'm here to help you with any issues you may have. Let me know how I can assist you!
To make Nuxt apps work with @teambit and Vitest when running tests programmatically, ensuring they render properly even if the current working directory is not the root path of the project, you can use the defineVitestConfig from @nuxt/test-utils/config and set the test environment to 'nuxt'. Additionally, you can use the getVitestConfigFromNuxt function to dynamically load and configure the Nuxt environment. Here is an example configuration:
This configuration ensures that the Nuxt environment is properly set up for your tests, which helps in rendering the Nuxt app correctly regardless of the current working directory. The getVitestConfigFromNuxt function dynamically loads the Nuxt configuration, making it adaptable to different project structures [1][2].
Details
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
Environment
The background is I'm trying to make the Nuxt apps work in @teambit.
I tried to run Vitest via Node APIs and have found the app doesn't render properly in the tests if the current working dir is not the root path of the project.
Reproduction
https://github.com/Jinjiang/reproductions/tree/nuxtjs-vitest-20240514
Describe the bug
First, prepare a js file
./debug/run.mjs
like:then:
node ./debug/run.mjs
, it workscd debug && node ./run.mjs
, it doesn'tAdditional context
No response
Logs
The text was updated successfully, but these errors were encountered: