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]: APIRequestContext query params displays undefined #34617

Open
vethman opened this issue Feb 4, 2025 · 0 comments
Open

[Bug]: APIRequestContext query params displays undefined #34617

vethman opened this issue Feb 4, 2025 · 0 comments

Comments

@vethman
Copy link

vethman commented Feb 4, 2025

Version

1.50.1

Steps to reproduce

  1. Clone my repo at: https://github.com/vethman/playwright-undefined-query-params.git
  2. npm i
  3. run tests
  4. 1 test fails

Expected behavior

When passing a undefined value as param to the apirequest I expect to not see this param in the URL.

Actual behavior

I see the key with value undefined as query param in the URL:

Expected: "https://example.com/api/getText?isbn=123456"
Received: "https://example.com/api/getText?isbn=123456&page=undefined"

Additional context

I don't like to have al the logic in my test layer. I have an actual architecture where I have multiple layers and finally I am able to pass the params with or without the optional values. So it is possible an optional value is made undefined.

Environment

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1265U
    Memory: 16.37 GB / 31.83 GB
  Binaries:
    Node: 22.5.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.96.4 - C:\Users\ROB8094\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  npmPackages:
    @playwright/test: ^1.50.1 => 1.50.1
@vethman vethman changed the title [Bug]: [Bug]: APIRequestContext query params displays undefined Feb 4, 2025
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

1 participant