Mike F
Mike F
SSolidJS
Created by Mike F on 1/31/2024 in #support
Vitest support
I was hoping to migrate my TypeScript and SolidJS project template from using Jest to Vitest for a nice little speed boost and to reduce my number of dependencies, but I'm encountering some errors. I'm trying to find out what I'm doing wrong, or if Vitest support just isn't fully baked yet. I've got this on a GitHub branch here: https://github.com/mikefarquhar/typescript-solid-application/tree/vitest_testing I'm using Node v20 and NPM v10.4.0 My package versions are up-to-date in the lockfile as of the time of writing so I don't believe I'm seeing issues with out-of-date package versions. The errors I've been seeing are: 1. "You appear to have multiple instances of Solid. This can lead to unexpected behavior." I've seen this pop up in a number of GitHub issues posts, but they look to have been resolved. None of the solutions in said posts are working for me though. I've made sure that there is only one copy of SolidJS in my project, so I assume something between vite, vitest and vite-plugin-solid is somehow making Solid load twice. 2. "computations created outside a createRoot or render will never be disposed" This shows up once per test unless I add
deps: {
optimizer: {
web: {
exclude: ["solid-js"],
},
},
},
deps: {
optimizer: {
web: {
exclude: ["solid-js"],
},
},
},
This error shows up regardless of whether I'm using any reactive signals or effects. Adding the above to the test config however causes the next problem. 3. Signals will update values in the browser, but fail to do so within the Vitest environment. This is as it sounds. I've effectively followed the basic example from the docs and the count never updates if the config above is set. Any help or guidance would be appreciated, even if the advice is to just continue using Jest for now.
14 replies