Replies: 2 comments
-
I have fixed this by providing the following export const apiClient = ky.extend({
...otherOptions,
prefixUrl: location.origin,
}); This does mean you have to remove the |
Beta Was this translation helpful? Give feedback.
-
Interesting that it works with If it does, then it means jsdom is not properly implementing As an aside, I would strongly recommend using Playwright instead of jsdom. It's a much more realistic test environment and still very fast and easy to set up. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I’m migrating to ky in my project and facing an issue while testing in a Jest environment. In the browser, everything works perfectly fine with relative URLs, but my tests fail with the following error:
Setup:
Problem:
Relative URLs (e.g., /example/api) work fine in the browser but fail in the Jest environment. I understand that this might be because Node.js (or jsdom) lacks a document.baseURI, which the browser naturally provides for resolving relative URLs. The thing is that once I replace
ky
withfetch
the problem goes away.Any help, advice, or best practices would be greatly appreciated! 😊
Beta Was this translation helpful? Give feedback.
All reactions