-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Which project does this relate to?
Start
Describe the bug
I am consistently getting errors with Vitest and TanStack Start when trying to unit test a component that has a useState() hook. I've searched extensively for documentation and among other issues, but have not found anything that addresses this issue.
- Using the latest dependencies
- Using the suggested approach for testing components
- I have a minimum reproducible example below
https://github.com/endymion1818/tanstack-test-vitest
Your Example Website or App
https://stackblitz.com/~/github.com/endymion1818/tanstack-test-vitest
Steps to Reproduce the Bug or Issue
- Create a component that uses
useState - Create a unit test for that component with Vitest
- Run the test
- Observe error
Expected behavior
I expected the test to pass / fail successfully.
Instead I got the error mentioned in the title
Screenshots or Videos
Test output:
<html>
<head />
<body>
<div>
<div
style="padding: 0.5rem; max-width: 100%;"
>
<div
style="display: flex; align-items: center; gap: .5rem;"
>
<strong
style="font-size: 1rem;"
>
Something went wrong!
</strong>
<button
style="appearance: none; font-size: 0.6em; border: 1px solid; padding: 0.1rem 0.2rem; font-weight: bold; border-radius: .25rem;"
>
Hide Error
</button>
</div>
<div
style="height: 0.25rem;"
/>
<div>
<pre
style="font-size: 0.7em; border: 1px solid red; border-radius: .25rem; padding: 0.3rem; color: red; overflow: auto;"
>
<code>
Cannot read properties of null (reading 'useState')
</code>
</pre>
</div>
</div>
</div>
</body>
</html>
Platform
- Start Version: 1.145.3
- OS: Windows 10 and Linux (Pop!_os)
- Browser: Chrome and Firefox (although not relevant)
- Browser Version: FF 146.0
- Bundler: vite
- Bundler Version: 7.3.0
Additional context
Link above is minimum reproducible example, it's occurring in another app we are currently building.
westhouseit
Metadata
Metadata
Assignees
Labels
No labels