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]: Mock issue on Playwright 1.49+ using MPTS #162

Open
hcura-qa opened this issue Dec 23, 2024 · 5 comments
Open

[BUG]: Mock issue on Playwright 1.49+ using MPTS #162

hcura-qa opened this issue Dec 23, 2024 · 5 comments

Comments

@hcura-qa
Copy link

hcura-qa commented Dec 23, 2024

Describe the bug
After the Playwright update to version 1.49.0 (also tested with 1.49.1), the native Playwright mocking tool (route()) is not working anymore when running using Microsoft Playwright Testing service (MPTS).

The test using a mocked call is failing with the following error:

Error: Socks5 proxy rejected connection - ConnectionRefused
Call log:
  - → POST <undisclosed>
    - user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.33 Safari/537.36
    - accept: application/json, text/plain, */*
    - accept-encoding: gzip,deflate,br
    - accept-language: en-US
    - content-type: application/json
    - cookie: <undisclosed>
    - origin: <undisclosed>
    - referer: <undisclosed>
    - sec-ch-ua: "HeadlessChrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"
    - sec-ch-ua-mobile: ?0
    - sec-ch-ua-platform: "Windows"
    - content-length: 93

We suspect the issue might be caused with the recent architecture change related to Chromium headless, that can be found here: microsoft/playwright#33566

To Reproduce
Steps to reproduce the behavior:

  1. Run a test with a mocked call (using route() Playwright's native method)
  2. Perform a route.fetch() - reproducible with our app so far
  3. Observe

Screenshots
N/A

Setup information (please complete the following information):

  • Session Id: 82601638-f67d-4a8c-95bb-dc2db38b6a2d
  • Browser on which tests are executed: Chromium
  • Playwright Version: 1.49+
  • Client machine OS: Linux
  • OS requested on Service: Linux

Additional context
The affected test has no issues when running against our Github runners infrastructure. This is a 100% reproducible issue using Microsoft Playwright Testing Service.

@hcura-qa hcura-qa changed the title [BUG]: Mock is not supported on Playwright 1.49+ using PTS [BUG]: Mock is not supported on Playwright 1.49+ using MPTS Dec 23, 2024
@manikanta-addagatla
Copy link

Hi,
We couldn't reproduce this issue from our end. Tried with simple test using route() and test has passed.

Could you please provide a sample to repro the issue?

@hcura-qa
Copy link
Author

I've implemented a test with similar steps, but the issue is not happening here (sessionId 074d7a6b-906e-4d85-b5f1-5f7109290f31):

  test('generic mock test', async ({ page }) => {
    const searchString = 'hcura-qa';
    const mockedName = 'Mocked Name';

    await page.goto('https://gh-users-search.netlify.app/');
    await page.route(`*/**/users/${searchString}`, async (route) => {
      const response = await route.fetch();
      let body = await response.json();

      body.name = mockedName;

      await route.fulfill({
        status: 200,
        body: JSON.stringify(body),
      });
    });

    await page.getByTestId('search-bar').fill(searchString);
    await page.getByRole('button', { name: 'search' }).click();
    await expect(page.getByRole('heading', { name: mockedName, level: 4 })).toBeVisible();
  });

For us, when running our app using MPT service under CI, the referred failure is happening on line "const response = await route.fetch();".

It is not happening when using our infrastructure (github runners), and it happens when running over MPT service, with Playwright 1.49+, and it is not reproducible locally, that's why we think the issue is likely related to MPT.

@hcura-qa hcura-qa changed the title [BUG]: Mock is not supported on Playwright 1.49+ using MPTS [BUG]: Mock issue on Playwright 1.49+ using MPTS Dec 30, 2024
@Sid200026
Copy link
Member

Hi @hcura-qa, from the initial error message shared, I see that the User-Agent indicates Windows operating system while you had mentioned that the client OS is Linux. I'm assuming you are running tests using some proxy server which is running on Windows.

- user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.33 Safari/537.36
- sec-ch-ua-platform: "Windows"

Could you provide us with the below details which would help us investigate the issue further

  • The previous version in which your test was working with Microsoft Playwright Testing Service
  • Node version
  • Playwright configuration file
  • If you are using some http proxy or socksv5 in your tests
  • Client-side channel logs (Channel logs might contain some secrets like url, auth tokens, etc. Feel free to remove them before sending the logs)
    • You can get them by setting the environment variable DEBUG=pw:channel*
    • You can send this via email to [email protected]

@puagarwa
Copy link
Member

HI @hcura-qa , Gentle reminder if you got chance to look into above info.

@miguelofbc
Copy link

@puagarwa @Sid200026 We’ve successfully replicated the failure, but it’s now blocking an important initiative. @hcura-qa has already reached out to the suggested contact via email. Could you please take a look at this as soon as possible? If the logs we’re sharing aren’t sufficient to identify the issue, feel free to schedule time tomorrow for further debugging.

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

5 participants