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

POST request payload/body is null #46

Closed
tonycchung opened this issue Jan 18, 2023 · 2 comments
Closed

POST request payload/body is null #46

tonycchung opened this issue Jan 18, 2023 · 2 comments

Comments

@tonycchung
Copy link

Hello! Thank you for this adapter - it works great for recording GET requests but I am having trouble with POST requests - namely getting the request body to be passed along through polly.

I am configuring the adapter with playwright by overriding the playwright page fixture like so:

import { test as base } from "@playwright/test";
import { Polly } from "@pollyjs/core";
import FSPersister from "@pollyjs/persister-fs";
import { PlaywrightAdapter } from "polly-adapter-playwright";

const test = base.extend<{ polly: Polly }>({
  page: async ({ page }, use, testInfo) => {
    Polly.register(PlaywrightAdapter);
    Polly.register(FSPersister);

    const polly = new Polly(testInfo.titlePath[0], {
      adapters: ["playwright"],
      adapterOptions: {
        playwright: {
          context: page,
        },
      },
      recordFailedRequests: true,
      persister: "fs",
      persisterOptions: {
        fs: {
          recordingsDir: "./tests/recordings",
        },
      },
      recordIfMissing: true,
      matchRequestsBy: {
        headers: false,
        body: false,
      },
    });

    await use(page);
    await polly.stop();
  },
});

export default test;

I see that this is where we pass the body from the original request:
https://github.com/redabacha/polly-adapter-playwright/blob/main/src/PlaywrightAdapter.ts#L103

but when I inspect this request.postData() I am finding it always to be null, even though the original request has the body as expected which I can see in the DevTools network tab (request and payload covered up):

Screen Shot 2023-01-17 at 6 12 51 PM

Do you think this is a potential issue with the playwright type not returning the correct post body data or should we be trying to grab this from elsewhere in the adapter?

thank you!

@redabacha
Copy link
Owner

hi @tonycchung!

thanks for opening this issue and i think you're indeed correct. it's highly likely that request.postData() being null is the consequence of a chromium bug unfortunately, see microsoft/playwright#6479 and microsoft/playwright#9648 for more details.

@tonycchung
Copy link
Author

ah i see - thank you for the prompt response and links to the sources - looks like it is finally being worked on but I suppose I'll just switch to firefox or webkit for now.

Thank you so much!

Cheers

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