nuxt / test-utils

🧪 Test utilities for Nuxt
http://nuxt.com/docs/getting-started/testing
MIT License
287 stars 74 forks source link

Cant fetch external URL #796

Closed MickL closed 3 months ago

MickL commented 3 months ago

Environment

------------------------------
- Operating System: Darwin
- Node Version:     v21.6.1
- Nuxt Version:     3.11.0
- CLI Version:      3.10.1
- Nitro Version:    2.9.4
- Package Manager:  bun@1.0.29
- Builder:          -
- User Config:      -
- Runtime Modules:  -
- Build Modules:    -
------------------------------

Reproduction

$fetch(`https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png`);

Describe the bug

Fetching an external URL doesnt work. The url is prefixed, e.g. the upper created http://127.0.0.1:56107https://www.google.de...

Additional context

An external URL needs to be fetched, e.g. when checking if a file has really been uploaded to AWS S3 or Vercel Blob.

Logs

No response

danielroe commented 3 months ago

Ah, very linked to your other issue and my comment there: https://github.com/nuxt/test-utils/issues/801#issuecomment-2013246787.

The $fetch helper from @nuxt/test-utils/e2e is not for fetching anything but from your test fixture. You can use another fetch helper, like the one from ofetch, for external fetches.

(We might consider this as an improvement in future - wdyt @pi0?)