Jest-puppeteer: Timeout still happening when using jestPuppeteer.debug().

Created on 10 Aug 2018  ·  10Comments  ·  Source: smooth-code/jest-puppeteer

Using await jestPuppeteer.debug(); in my test, it enters debug mode for a moment and then I get this error:

Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

and:

Jest did not exit one second after the test run has completed.

Using versions:
[email protected]
[email protected]
[email protected]

bug 🐛

Most helpful comment

Hmmm, weird. The only way I can get it to work is:

it('like this', async () => {
  await jestPuppeteer.debug()
}, 999999)

All 10 comments

Hello @tybro0103, can you paste the code of your test?

@neoziro This is all it takes:

describe('foo', async () => {
    it('bar', async () => {
        await page.goto(`http://localhost:${port}/foobar`, {waitUntil: 'networkidle2'});
        await jestPuppeteer.debug();
    });
});

I've found that if I add a large timeout as the 3rd argument to it() I can get around it, but that's not ideal. I saw in the Jest docs that the timeout has to be set _before_ the test runs... perhaps that's something new in v23?

I just tried and it works, but it does not work if timeout if set in the test. I will ask about Jest team to find a real solution to stop the execution of the test. Today I am using jest.setTimeout(xx) in the jestPuppeteer.debug() method but it doesn't seems to be enough to pause the test.

Did you mean to say "but it does not work if timeout is [not] set in the test"?

it('does not work', async () => {
  await jestPuppeteer.debug()
}, 3000)

it('works', async () => {
  await jestPuppeteer.debug()
})

Hmmm, weird. The only way I can get it to work is:

it('like this', async () => {
  await jestPuppeteer.debug()
}, 999999)

Yeah it is very weird.

I'm getting the following error when using await jestPuppeteer.debug()

TypeError: stdin.setRawMode is not a function

docker => node:10.9.0-alpine
deps =>

-- [email protected]
-- [email protected]
-- [email protected]

Also test timeout much earlier than expected.

I have a somewhat related issue:
My tests are succeeding, but I'm getting the following output in the end:

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
(node:18236) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
    at Promise.then (/Users/username/Projects/projectname/node_modules/puppeteer/lib/NavigatorWatcher.js:94:21)
    at <anonymous>
(node:18236) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18236) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨  Done in 36.97s.

When I add anything to the end of my last test that suspends its finalization the error message disappears. For example:

await jestPuppeteer.debug()

Or:

await new Promise((resolve) => setTimeout(resolve, 100))

However, this would just be a dirty workout and not a solution to the problem. I also tried setting a timeout of 10 seconds by providing a timeout argument to the test. But it didn't work.

As the process doesn't exit with an error because of that I'll probably just live with it.
I still wanted to bring it to your attention as this is something worth resolving.

If someone is able to reproduce this we can reopen it but it seems to work fine in the latest version.

If you are getting Jest did not exit one second after the test run has completed. when using jestPuppeteer.debug() it is most likely because you forgot to add await before it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshpitzalis picture joshpitzalis  ·  3Comments

undrafted picture undrafted  ·  4Comments

Greg-oliver99 picture Greg-oliver99  ·  4Comments

xiaoyuhen picture xiaoyuhen  ·  5Comments

songguohfut picture songguohfut  ·  6Comments