Skip to content

[Feature] request.postData to return json string instead of urlsearchparams #1686

@aesyondu

Description

@aesyondu

I noticed that when using route to assert postData:

page.route("some-route", (route, request) => {
  expect(request.postData()).toMatchObject({ foo: "bar" })
})

that it returns a string of search params foo=bar&baz=bum.

Does it make sense to make it return a json string instead?

Reference commit: aesyondu@1b3929d, with test case and sample naive implementation

Given:
A form with input type text, input type number, and input type submit

await page.setContent(`<form method='POST' action='/post'><input type='text' name='foo' value='bar'><input type='number' name='baz' value='123'><input type='submit'></form>`);
await page.click('input[type=submit]');
expect(request).toBeTruthy();
expect(request.postData()).toBe('{"foo":"bar","baz":"123"}');

When:
Form data is submitted via POST method.

Then:
request.postData() should return a json string: {"foo":"bar","baz":"3"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions