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

Pausing test #6855

Closed
gregberge opened this issue Aug 16, 2018 · 7 comments
Closed

Pausing test #6855

gregberge opened this issue Aug 16, 2018 · 7 comments

Comments

@gregberge
Copy link
Contributor

I am the creator and the maintainer of Jest Puppeteer. It brings integration testing into the Jest world.

Writing integration test is not very easy, frequently you have to pause your test to figure out what's going on in the browser. For this specific use case I added a debug mode to Jest Puppeteer. It is simple, you add : await jestPuppeteer.debug() and your test wait at this line until you press a key.

Actually the debug mode implementation is very hacky, I set Jest timeout to 4 days. But unfortunately the test has already start and it does not work well.

Is it possible to suspend the execution of a test in Jest? I am looking forward to find a solution to make it work! Thanks!

@SimenB
Copy link
Member

SimenB commented Aug 16, 2018

Setting the timeout programatically from within a test will stop working in the future, you'll need to supply the argument to the test function (or set it in a hook).

You can then use e.g. https://github.com/sindresorhus/delay to wait for some time.

test("this needs to wait", async () => {
  // Do some stuff

  await delay(1000000);

  // Do some more stuff
}, 1000000);

I'm not sure if it's possible to be more clever, from core or the outside. Maybe by applying some fancy babel transforms, but that might be excessive (and I don't know what they would do).

/cc @aaronabramov @rickhanlonii @thymikee

@aaronabramov
Copy link
Contributor

@SimenB why are we getting rid of setting the timeout programmatically? :)
i remember we had a conversation about it in LON, where we decided to ignore jest.setTimeout() because it introduced some complexity with dynamic checking for timeout value every time.
this use case seems like a valid usecase though and since supporting dynamic jest.setTimout is pretty simple to implement i think we might just wanna do it

@SimenB
Copy link
Member

SimenB commented Aug 16, 2018

Sounds even better 🙂 I thought we landed on that changing the timeout from within a test was weird and confusing, but I suppose we could also make it work properly 🙂

@SimenB
Copy link
Member

SimenB commented Aug 16, 2018

That said, you don't really need to change the timeout. There's no real way to interrupt the execution of a JS program, so as long as you set a breakpoint you'll be able to inspect the test any way you want (the test will timeout, but that only happens afterwards, the code still runs)

@gregberge
Copy link
Contributor Author

I cannot set a breakpoint without being in debug mode.

Actually setting the timeout in the test is inconsistent, it works when a timeout is not set but it doesn't if a timeout is set in test / it.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

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

3 participants