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

[Feature]: Allow route fulfillment with a readable stream body #33564

Open
zakhenry opened this issue Nov 13, 2024 · 0 comments
Open

[Feature]: Allow route fulfillment with a readable stream body #33564

zakhenry opened this issue Nov 13, 2024 · 0 comments

Comments

@zakhenry
Copy link

zakhenry commented Nov 13, 2024

🚀 Feature Request

Currently, Route.fulfill only accepts string|Buffer as body type. Add nodejs type ReadableStream to permit streamed calls.

Example

const bodyStream = new Readable();

await page.route('**/*', async route => {
 route.fulfill({
    status: 200,
    contentType: 'application/grpc-web+proto',
    body: bodyStream
  });
});

// @todo interact with page

bodyStream.push(chunk);
// @todo  assert on DOM state

bodyStream.push(chunk);
// @todo assert on updated DOM state

bodyStream.destroy();
// @todo assert request completed

Motivation

There are several use-cases where this is useful:

  1. stubbing grpc-web calls that are server streaming - the test script could push events into the stream and assert the expected in-progress result is displayed in the webview
  2. stubbing server-sent events
  3. stubbing streams of other kinds (live video?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants