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
Hello,
as developer I want to render data on the server. QA wants to intercept requests to return a fixture data. I'm using a standalone Playwright—after build is done, npx playwright test does its job.
If I have the following function in the Pinia:
// Store
async function fetchData(slug) {
try {
const { data } = await useFetch(`/internal/content/page?name=${slug}`);
page.value = { ...data.value };
} catch (e) {
console.error(e);
}
}
useFetch is pre-fetched on the server, which is good for the end user. Testers cannot intercept /internal/content/page as the client does not send requests.
If I change to $fetch, playwright test can intercept the request.
I'm reading through API, documentations, and unit tests, but can't find an answer to the question how can I force sending request on the client for a given environment, or **how to globally disable pre-fetching for a given environment`.
A very dirty solution:
To make it more portable, it could be probably moved into a custom fetch. useFetch returns data which is a ref, while $fetch returns just data. How to do it in a clean way, not breaking the API of $fetch and useFetch, I do not know. useFetch also returns for example pending and I would not like to over engineer the wrapper.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
as developer I want to render data on the server. QA wants to intercept requests to return a fixture data. I'm using a standalone Playwright—after build is done,
npx playwright test
does its job.If I have the following function in the Pinia:
useFetch
is pre-fetched on the server, which is good for the end user. Testers cannot intercept/internal/content/page
as the client does not send requests.If I change to
$fetch
, playwright test can intercept the request.I'm reading through API, documentations, and unit tests, but can't find an answer to the question how can I force sending request on the client for a given environment, or **how to globally disable pre-fetching for a given environment`.
A very dirty solution:
To make it more portable, it could be probably moved into a custom fetch.
useFetch
returnsdata
which is aref
, while$fetch
returns just data. How to do it in a clean way, not breaking the API of$fetch
anduseFetch
, I do not know.useFetch
also returns for examplepending
and I would not like to over engineer the wrapper.Looking forward to your replies!
Beta Was this translation helpful? Give feedback.
All reactions