hey I m using vitest for testing and

hey! I'm using vitest for testing, and "suddenly" (in quotes as I can't figure out how I broke it) I get the following error:
TypeError: Cannot set property crypto of #<Object> which has only a getter
❯ Object.setup node_modules/vitest-environment-miniflare/src/index.ts:80:11
❯ Module.withEnv node_modules/vitest/dist/chunk-runtime-setup.667a5719.js:888:15
886| files.map(async (fsPath) => {
887| getWorkerState().moduleCache.delete(fsPath);
888| await import(fsPath);
| ^
889| })
890| );
❯ run node_modules/vitest/dist/entry.js:91:7
❯ node_modules/tinypool/dist/esm/worker.js:109:20
TypeError: Cannot set property crypto of #<Object> which has only a getter
❯ Object.setup node_modules/vitest-environment-miniflare/src/index.ts:80:11
❯ Module.withEnv node_modules/vitest/dist/chunk-runtime-setup.667a5719.js:888:15
886| files.map(async (fsPath) => {
887| getWorkerState().moduleCache.delete(fsPath);
888| await import(fsPath);
| ^
889| })
890| );
❯ run node_modules/vitest/dist/entry.js:91:7
❯ node_modules/tinypool/dist/esm/worker.js:109:20
9 Replies
MrBBot
MrBBot2y ago
Hey! 👋 Were you able to get tests running successfully with vitest-environment-miniflare before? Have you upgraded any packages recently?
honzabit
honzabitOP2y ago
hey! yeah, I use vitest for some months on this project, running tests multiple times daily, and for some reason I can't understand what changed .. I was just writing a new module and this triggered when I started testing it .. super strange, and ofc I know that I caused it .. but I even rollbacked to some versions back from my repo, and still get the same error (always rm -rf node_modules and npm i before testing it) .. I have no idea what I broke and how 😄 i also tried removing the miniflare environment from vitest and tried to initiate the tests using the mf api, but it wasn't so much successful also tried to use the ultimate console.log() in nodemodules to understand where exactly it breaks, and got inside getGlobalScope() in the shared-test-environment package, where it was failing before await this.#initPromise; ¯_(ツ)
MrBBot
MrBBot2y ago
Hmmmm 🙃 when you did rm -rf node_modules, did you also rm package-lock.json?
honzabit
honzabitOP2y ago
negative 🙂 I'll give it a shot again, I'll let you know if anything change 🙂 nah, same error (without the trace though as I was using an older vitest version at the point of this branch) .. miniflare 2.10.0 + vitest-environment-miniflare 2.10.0 + vitest 0.24.0 I cannot pinpoint it to a changed version of these three packages .. this is the problem..
MrBBot
MrBBot2y ago
Which node version are you using?
honzabit
honzabitOP2y ago
v19.1.0 I will now try to re-create the project from scratch on a clean directory and check what's happening
MrBBot
MrBBot2y ago
Hmmm, could you try on 16? Haven't tested Miniflare 2 on Node 19 yet. I'd recommend https://volta.sh/ if you're not already using a Node version manager.
honzabit
honzabitOP2y ago
sure, i'll give it a shot and report back, thanks! ok, 3 things! 1) volta rocks 😄 2)
Test Files 14 passed (14)
Tests 79 passed (79)
Test Files 14 passed (14)
Tests 79 passed (79)
and 3) I have no idea what happened 😄 I really didn't mess with the node version at least today but anyways, thanks a lot once again for all your work 😄
MrBBot
MrBBot2y ago
No problem! 🙂 Glad it's all working again.
Want results from more Discord servers?
Add your server