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] Route api show unwanted logs #28859

Closed
Piero87 opened this issue Jan 4, 2024 · 1 comment
Closed

[BUG] Route api show unwanted logs #28859

Piero87 opened this issue Jan 4, 2024 · 1 comment

Comments

@Piero87
Copy link

Piero87 commented Jan 4, 2024

System info

  • Playwright Version: [v1.40.1]
  • Operating System: macOS 14.2.1
  • Browser: All
  • Other info:

Source code

await this.page.route(
      '**/*',
      async (route) => {
        try {
          // Make the original request
          const url = route.request().url();

          if (["json.php", "api/v3"].some(el => url.includes(el))) {
            
            const response = await route.fetch();

            const data = await response.json();
            const statusCode = await response.status();

            route.fulfill({ json: data, status: statusCode });
          } else {
            route.continue()
          }
        } catch (error) {
          console.log(error);
        }

      }
    );

Steps

  • [Run the test]
  • [...]

Expected

Log in the terminal shoudl show only information about test

Actual

Now I see other logs unwanted and only at the bottom the result of the test:

route.fetch: Test ended.
Call log:
  - → GET https://***/api/v3/tt_e2e_test_sc165969d685700f/downloads/sc163ad4c4dd924a/shares?version=1.1&lang=it
  -   user-agent: Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.28 Mobile Safari/537.36
  -   accept: application/json, text/plain, */*
  -   accept-encoding: gzip,deflate,br
  -   accept-language: en-US
  -   authorization: Bearer ******
  -   content-type: application/json
  -   origin: http://local.tuotempo.net
  -   referer: http://local.tuotempo.net/
  -   cookie: lang=it; PHPSESSID=*****

    at /Users/piero/****/dev/tests-e2e/packages/mop/src/pom/mop-page.ts:105:42
  5 passed (37.2s)
@mxschmitt
Copy link
Member

Folding into #23781

We'll implement a feature to address this is in the next release. As a workaround you can do for now:

route.fulfill() -> route.fulfill().catch(() => {});
route.continue() -> route.continue().catch(() => {});

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