Closed MickL closed 6 months ago
You won't be able to fetch from your Nuxt app because it is initialised in beforeAll, and torn down in afterAll. But you can fetch from other places, just not using the $fetch
from @nuxt/test-utils/e2e
, which is only for getting data from a running Nuxt server. You, could, for example, import { $fetch as externalFetch } from 'ofetch'
and that should work fine anywhere in your test suite.
Environment
Reproduction
https://stackblitz.com/edit/github-krtpdn-tvzxcc?file=test%2Fsomething.spec.ts
Describe the bug
Within
beforeAll()
andafterAll()
I cant usefetch
or$fetch
.Error in beforeAll():
Error in afterAll():
Additional context
It is crucial to test server endpoints to do some work within beforeAll and afterAll, e.g. prepare the database by creating some items and in the end cleaning everything up again.
Logs
No response