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
14 Replies
This usally means you've got multiple versions of Vitest installed? Could you try run
npm why vitest?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
Ah yeah, we had the exact same problem in the
workers-sdk monorepo.I have the exact same monorepo setup (pnpm + turborepo), so maybe that's why
I ran
pnpm -r update vitest@1.3.0 and it removed this:
and left this one:

I guess the duplicate vitest entry started breaking things
(no idea how that got there)
All good now though! :party_blob:

LOVING the new vitest runtime @MrBBot :MeowHeartCloudflare:
I have around 30 Workers in this monorepo that I'm adding tests to
Wohoo! 🎉
(and you had perfect timing cause I'm building several new Workers internally that I started last week that I can use this for!)
Progress!

One thing I noticed as I add vitest to more projects in my monorepo is that the first test takes a while to start

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)