We have an NX monorepo, where each library has a vite.config.mts file that looks like this:
import { makeConfig } from '../../../vite.config.base'
export default makeConfig({
name: 'library-name',
pathToRepoRoot: '../../../',
projectDir: __dirname,
})
If I want to run a test through the Vitest Test Runner, it only works if I specify the full absolute path for the library's vite.config.mts in the "Configuration file" field of the run config. If I leave this out, the test runner complains of being unable to find code from other libraries, as well as Vitest globals like describe.
Running the nx targets to run the tests from the terminal (or through the WebStorm NX plugin as a run config) works fine but this is much less flexible than the test runner of course.
For individual files, this is a pain (I should just be able to click the gutter icon and have it just work) but still possible. However, if I want to run "All Tests" then obviously I can't supply all the config paths for all the libraries. How would I make this work?
Similarly, if I wanted to more easily set up a config for any individual file, how would I do this? The test runner always runs Vitest and simply supplies the filename as an argument. Therefore there's not even any way to get something like $currentFilelibraryRoot/vite.config.mts since there's not even really a concept of "currentFile".
For what it's worth, Vitest runner used to "just work" in our project. Although for some reason I'm unable to use git bisect to diagnose this, I think it broke in a commit that switched from using vite.config.js to vite.config.mts, along with a few other things such as upgrading vite and vitest.
Did just the change in the config filename make this difference? Since specifying the mts file does work, as indicated above, I don't think the issue is the difference between the contents of the old js file (and the config it built from vite.config.base) and the new mts file.
I thought it was maybe as simple as WebStorm's Vite runner is (no longer) finding the "closest Vite config file" when that file is .mts, but changing the filename to vite.config.js doesn't fix it!