-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
jsdom screenshot gets stuck #268
Comments
Hey, @pvieira91. Thanks for reaching out. Please, does your test pass without being stuck when you remove API mocking?
|
|
Thanks for providing the insights. I don't see anything that would have caused a screenshot generation to hang. I've been tackling with an issue that would result in a POST request with a body to hang a request forever in Node (#275) recently. That may be the case if Could you please set up a minimal reproduction repository for this issue? |
I have a suspicion to believe that the issue happens due to the combination of how
Most likely it hangs forever because the network is never idle and there is some pending request. I don't know how the NodeJS request interception can affect Puppeteer's runtime, to be honest, as it only intercepts requests in the current process (Puppeteer spawns Chromium in a new process, plus, it's a browser environment). In my experience such hanging may be caused by improper handling of the Service Worker. Do you establish any client-side interception as a part of |
Hello @pvieira91! I did a little research into this earlier and set up a working repo here: https://github.com/msutkowski/msw-jsdom-snapshot-repro The highlights are that you need to currently change the As an example, you can eliminate the beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
it("should have no visual regressions while rendering the greeting", async () => {
const { getByTestId } = render(<App />);
await waitFor(() => getByTestId("greeting"));
expect(getByTestId("greeting")).toHaveTextContent("hello, superbanana");
expect(
await generateImage()
).toMatchImageSnapshot();
}); Let me know if you have any questions, and I hope this helps you out and saves some time :) |
Puppeteer attempts to establish a WebSocket connection to its instance to make a screenshot. That connection (request) gets intercepted by Please consider launching your Puppeteer instance with
By setting Once we have a WebSocket support you should be safe to omit this option. |
Hi,
I've been using this tool to mock some api responses. It worked nicely until I tried to generate screenshots using the jsdom-screenshot. In the process of generating an image, JSDom launches a server on-the-fly (running on a random port). I found out that my tests were getting stuck on the generateImage step.
The following request never gets a response:
http://127.0.0.1:64667/devtools/browser/7c081340-c14d-4d6b-a8ed-7b3a8ba2fc2e
This looks like a request made by puppeteer. (devtools protocol)
Based on my search, msw should proxy pass all requests meaning that this shouldn't happen.
Here's the generateimage script from jsdom-screenshot
https://github.com/dferber90/jsdom-screenshot/blob/master/generateImage.js
A last note to thank you for this fantastic work.
Regards
PS: As a quick workaround, I'm closing the server before the step of image generating - instead of doing it on the afterAll. This means that I also need to server.listen before every test. Is that okay? Is there a method a more lightweight method to achieve that?
The text was updated successfully, but these errors were encountered: