Mocking api routes with playwright.
Unanswered
starlord posted this in #help-forum
starlordOP
What is the recommended way to mock api routes response in a playwright test where the api routes are being called by react query in server and client components?
1 Reply
starlordOP
I tried using the official playwright guide to mock requests like this, but it doesn't do anything
await context.route("http://localhost:3000/api/permissions", (route) => {
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(mockPermissions),
});
});