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] Auto close browser when launcher process exits #2261

Closed
jperl opened this issue May 15, 2020 · 5 comments
Closed

[Feature] Auto close browser when launcher process exits #2261

jperl opened this issue May 15, 2020 · 5 comments

Comments

@jperl
Copy link
Contributor

jperl commented May 15, 2020

It would be nice if the browser would automatically close when the parent process closes. When you are running a test and want to kill it early with CTRL+C, it will leave a hanging browser.

@aslushnikov
Copy link
Collaborator

@jperl I just tried and it does close for me. Do you launch browser with handleSIGINT: false?

@jperl
Copy link
Contributor Author

jperl commented May 15, 2020

It works with a regular node script, but not inside a Jest test.

https://github.com/jperl/pw-close-repro

This works, it closes the page and browser process: node ./example.script.js + CTRL+C
This does not work, it closes the page but leaves the browser process: npx jest + CTRL+C

Mac OS 10.15.4

@aslushnikov
Copy link
Collaborator

aslushnikov commented May 15, 2020

@jperl Ah! Awesome repro, thank you! I didn't understand it's jest-related. This issue was originally fixed in 2018 back in Puppeteer days: puppeteer/puppeteer#2428

So if you use something like jest v20, it'll work (verified).

However, jest v26 doesn't dispatch SIGINT anymore, so simple scripts like this won't work:

// this is `example.test.js`

// this will never be called
process.on('SIGINT', () => console.log('SIGINT!'));

test("demo", async () => {
  console.log('running test');
  await new Promise(() => {});
});

Is there any tear down hook that jest calls when terminating process?

Update: looks like a jest regression to me, filed upsteram as jestjs/jest#10052

@jperl
Copy link
Contributor Author

jperl commented May 16, 2020

Thank you for investigating 🙏

@pavelfeldman
Copy link
Member

Let's move this issue to the jest-related repo.

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

3 participants