Had a really strange issue where my

Had a really strange issue where my tests could no longer run due to AssertionError: Expected Vitest to start running before importing modules
No description
14 Replies
MrBBot
MrBBot•2y ago
This usally means you've got multiple versions of Vitest installed? Could you try run npm why vitest?
Jacob
JacobOP•2y ago
Looking through the diffs, I found out that this @types/node@18.15.3 thing got removed in my lockfile. Adding it back fixed it
No description
MrBBot
MrBBot•2y ago
Ah yeah, we had the exact same problem in the workers-sdk monorepo.
Jacob
JacobOP•2y ago
I have the exact same monorepo setup (pnpm + turborepo), so maybe that's why
Jacob
JacobOP•2y ago
I ran pnpm -r update vitest@1.3.0 and it removed this:
No description
Jacob
JacobOP•2y ago
and left this one:
No description
Jacob
JacobOP•2y ago
I guess the duplicate vitest entry started breaking things (no idea how that got there)
Jacob
JacobOP•2y ago
All good now though! :party_blob:
No description
Jacob
JacobOP•2y ago
LOVING the new vitest runtime @MrBBot :MeowHeartCloudflare: I have around 30 Workers in this monorepo that I'm adding tests to
MrBBot
MrBBot•2y ago
Wohoo! 🎉
Jacob
JacobOP•2y ago
(and you had perfect timing cause I'm building several new Workers internally that I started last week that I can use this for!)
Jacob
JacobOP•2y ago
Progress!
No description
Jacob
JacobOP•2y ago
One thing I noticed as I add vitest to more projects in my monorepo is that the first test takes a while to start
No description
Jacob
JacobOP•2y ago
so I had to add --testTimeout=15000 to make sure it doesn't fail due to taking >5000ms for the first test to run (which is fine, just putting this here in case someone else runs into the same issue)

Did you find this page helpful?