test(nuxt): Update Nuxt version and add Nitro $fetch test#17713
test(nuxt): Update Nuxt version and add Nitro $fetch test#17713
Conversation
| import { defineEventHandler } from '#imports'; | ||
|
|
||
| export default defineEventHandler(async () => { | ||
| const data = await $fetch('https://ungh.cc/orgs/unjs/repos'); |
There was a problem hiding this comment.
l/m: Never heard of ungh.cc, do we want to depend on this in the e2e tests? Wonder if example.com is not better.
I remember we've had issues with example.com too tho, so not sure.
There was a problem hiding this comment.
I'd recommend avoiding external requests entirely and just intercept the request in playwright. Examaple:
(not sure how consistent we are with this in e2e tests but this is what we do in the browser integration tests)
There was a problem hiding this comment.
That's the endpoint that Nitro uses in their examples: https://nitro.build/guide/fetch
But intercepting sounds like a good idea 👍
There was a problem hiding this comment.
Turns out it's not that straightforward to use page.route here. As the request is not made by the browser but the nitro server, it is not intercepted. And I cannot just call another Nitro server route as Nitro does not create a separate requests when it's within the server. For the test however, I want to specifically test calling an external API and example.com is okay for this case as the test does not fail if the endpoint cannot be reached. It's just about adding the span.
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
This PR adds the following:
$fetchrequestsapp.vuefile as this is not needed when using theapp/pagesdirectory (following the Nuxt docs)