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

defineVitestConfig not respecting custom configFile #498

Closed
mattkatt opened this issue Apr 3, 2023 · 2 comments
Closed

defineVitestConfig not respecting custom configFile #498

mattkatt opened this issue Apr 3, 2023 · 2 comments
Labels
enhancement New feature or request vitest-environment

Comments

@mattkatt
Copy link

mattkatt commented Apr 3, 2023

Im attempting to create a nuxt.config file for running tests (named nuxt-test.config), which contains additional configuration for running tests that I do not want in the build config. I am attempting to pass the name of the config file into defineVitestConfig, but when running vitest, it's still is using the default nuxt.config file, which is failing tests. If the appropriate configs are moved from the test config into the default then tests run fine.

Example error steps to duplicate:

  1. Install nuxt-vitest into a fresh nuxt project
  2. Create a new nuxt-test.config file containing the module import:
    export default defineNuxtConfig({
        modules: ['nuxt-vitest'],
    })
    
  3. Create a vitest.config file using defineVitestConfig, passing in the following config:
    export default defineVitestConfig({
        configFile: 'nuxt-test.config',
    })
    
  4. run vitest

This will cause vitest to error as it complains that the 'nuxt-vitest' module is not defined in 'nuxt.config'.

@danielroe
Copy link
Member

Yes, the configFile option there is a vite config file, rather than a nuxt one. Would you consider adding a local module which includes all your test config?

We could also support a custom nuxt config file but that's not that common in the rest of the Nuxt ecosystem.

@danielroe danielroe added the enhancement New feature or request label May 2, 2023
@danielroe
Copy link
Member

It's now possible to define nuxt configuration overrides in your vitest config via test.environmentOptions.nuxt. Does that solve this issue for you?

@danielroe danielroe transferred this issue from danielroe/nuxt-vitest Dec 2, 2023
@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vitest-environment
Projects
None yet
Development

No branches or pull requests

2 participants