Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Mocking GQL calls does not work - route.request().PostData(), route,fetch() not working for chromium #24572

Closed
devnigam24 opened this issue Aug 2, 2023 · 1 comment

Comments

@devnigam24
Copy link

System info

  • Playwright Version: 1.32.0
  • Operating System: Node 14
  • Browser: Chromium
  • Other info: Firefox works

Source code

Just trying to do as simple as mocking all Graph QL calls so that I can identify which one is mine and mock that.

await page.route(**/graphql', async (route) => {
    console.log({postData:JSON.parse(route.request().postData() as string)}) => null 
    console.log({postDataJSON:route.request().postDataJSON()}) => null

    const response = await route.fetch(); => 400 error
    console.log({response});
    const json = await response.json();
    console.log({json});

    await route.fulfill({ response, json });
  });

In Firefox it all works like a charm.

Found some other issues related to this
Looks like still related to
Chromium Bug

If its still indeed a chromium issue, is there a workaround for identifying one graphQL call and mocking that one, and continuing the rest untouched?

Thanks

@yury-s
Copy link
Member

yury-s commented Aug 3, 2023

If its still indeed a chromium issue, is there a workaround for identifying one graphQL call and mocking that one, and continuing the rest untouched?

Unfortunately there is no way currently to discriminate such requests based on post data. You could try changing the sending code to add some header or a url param, but that would require changing the app code.

Merging the report into #6479, please upvote that one instead.

@yury-s yury-s closed this as completed Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants