Jest: Be able to temporarily pause test --watch runner.

Created on 20 Jun 2018  Ā·  12Comments  Ā·  Source: facebook/jest

šŸš€ Feature Proposal

Provide a way to pause --watch mode so it stops listening to changes without actually killing the process.

Motivation

Watch mode is super useful, and I often find it repeatedly running up to a hundred related tests while I'm refactoring stuff and toggling among windows. It'd be great to tell it to chill out, pause, and then resume when prompted without actually killing/restarting the process.

It seems simple into to just quit and restart, but I was just surprised there isn't a way to simple tell it to simmer down for a period of time.

Most helpful comment

A plugin should be able to achieve this... I’ll add more details later tonight.

The basic idea would be ā€œpress s to pauseā€ and that would clear the screen and show you a message saying ā€œJest is paused, press any key to resumeā€

All 12 comments

Really cool - can this be done with a custom watch mode plugin?

You can work around it by setting a dummy test path/name. It'll still watch, but not trigger any tests.

Not sure if it's possible to do currently without a hack like that. Might need a change in core first? Haven't dug into it, though

I've never poked around in the source of Jest, but you if you have any suggestions on where to start I'd be happy to look into it.

Based on @SimenB idea, one could create a watch plugin passing empty testNamePattern to config like here: https://github.com/jest-community/jest-watch-typeahead/blob/1b6dbfb4237b07a5c96716f418a621ac72ac9871/src/test_name_plugin/plugin.js#L52

A plugin should be able to achieve this... I’ll add more details later tonight.

The basic idea would be ā€œpress s to pauseā€ and that would clear the screen and show you a message saying ā€œJest is paused, press any key to resumeā€

It would be very useful for Jest Puppeteer. Actually we have jestPuppeteer.debug() but it does not stop the test completely. Do you have a current solution to pause a test (avoiding timeout)?

You are probably thinking of something different. I'm proposing a feature to pause the watch functionality, not to pause a test.

Yes I am thinking about a way to pause a test. I will open another issue.

+1

+1

This can be implemented as a custom watch plugin, see https://jestjs.io/docs/en/watch-plugins

If anybody does this, please send a PR to awesome-jest to add it to the list of watch plugins there!

For reference: This is now implemented by this plugin https://github.com/unional/jest-watch-suspend

Was this page helpful?
0 / 5 - 0 ratings