Cody Bontecou
Explore posts from serversTest Utils + Vitest + MSW - potential caching issue
I'm using a combination of
"@nuxt/test-utils": "^3.12.1",
, "vitest": "^1.5.0",
and "msw": "^2.2.14",
to test my Nuxt application.
Everything works great, except I'm running into an issue when attempting to mock a specific http request using MSW (https://mswjs.io/):
In this case, I'm trying to do a one-off network override (https://mswjs.io/docs/best-practices/network-behavior-overrides). This doesn't actually override the HTTP request, and instead provides the response from my initial mock that is passed to my MSW server.
I'm happy to get deeper into the details if you're interested, but the question I have is related to caching.
This problem is discussed a few times in the MSW github (https://github.com/mswjs/msw/issues/694#issuecomment-860570247), and the solution tends to be caching-related.
I haven't been able to find anywhere to disable or force-reset the vitest or nuxt test-utils cache besides https://vitest.dev/config/#cache, which had no effect.4 replies
Where to deploy with long-polling functions
I'm a bit confused where Nitro hangs out in the deployment space and how these deployed environments manage
setInterval
alongside Nitro endpoints.
I have a function that runs every 10 seconds and is currently managed in Nitro like so:
Does this run for a few seconds every interval, or is the setInterval
creating a long-running process that is never killed until the setInterval is killed using clearInterval(intervalId)
?
I imagine the latter would get expensive quickly in a serverless environment. Or, am I overthinking this?
My understanding is serverless is ideal for short-running bits of code, not for long-running processes, and in fact, serverless providers tend to have a time-limit on long-running code. Is there a more ideal way to deploy a Nuxt application that utilizes Nitro extensively and doesn't depend on a serverless backend?7 replies
What is the recommended route to using a 3rd-party composable that relies on the window object?
I'm playing with vue-plaid-link and ran into issues until I dug into the source and saw this line:
Specifically, the
window.Plaid.create
.
I was able to get this to working by disabling ssr in my nuxt config, but this is not ideal. I'd prefer to continue using ssr, while also being able to use this library.
What is the current recommended way of handling this? Is it plugins? Checking against the window object before using the composable?4 replies
Is there a useFetch alternative that allows me to call the server function without a string?
I might call a server endpoint like so:
I'd like to do something more trpc-like, allowing me to avoid the use of strings. Is this currently possible?
3 replies
E2E Type safety: What am I missing?
I'm exploring e2e type safety and am curious what I am missing.
Here's my server route:
And I consume this on the client like so:
I have to explicitly state the expected return type from the useFetch hook. I assumed this would be inferred from the backend.
Here's a reproduction: https://github.com/CodyBontecou/nuxt-e2e-types
1 replies