You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[nuxt] instance is not available in server utils unit tests with useRuntimeConfig() #949
After some recent dependancy upgrades around Nuxt I'm getting the [nuxt] instance unavailable error on tests that call functions in server/utils that use useRuntimeConfig.
The runtime environment for nuxt test utils is for testing client-side/browser code, rather than server code. (See #531.) So I wouldn't expect it to work.
Does code using useRuntimeConfig work fine when outside the server/ folder?
Activity
bolt-new-by-stackblitz commentedon Sep 16, 2024
danielroe commentedon Sep 18, 2024
The runtime environment for nuxt test utils is for testing client-side/browser code, rather than server code. (See #531.) So I wouldn't expect it to work.
Does code using
useRuntimeConfigwork fine when outside theserver/folder?alexcroox commentedon Sep 18, 2024
ah that's a real shame. It used to work before compatibility version 4 was introduced, here is a repro with it working fine in the old folder structure: https://stackblitz.com/edit/github-gu1sj1-xnyzbk?file=server%2Futils%2Fexample-util.nuxt.spec.ts&startScript=start
and yes useRuntimeConfig works outside the server folder in v4