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

Support disabling watch mode #613

Closed
jimmyzzxhlh opened this issue Aug 5, 2020 · 14 comments · Fixed by #674
Closed

Support disabling watch mode #613

jimmyzzxhlh opened this issue Aug 5, 2020 · 14 comments · Fixed by #674

Comments

@jimmyzzxhlh
Copy link

jimmyzzxhlh commented Aug 5, 2020

There doesn't seem to be a way to disable the watch mode. With watch mode on the tests are always running whenever there is a save action on any file in the workspace. When we have a decent number of tests in the workspace it takes some time to finish all tests, which causes a high cpu load on my machine (observed by just listening to the fan noise).

Is it possible to disable the watch mode so that we have the ability to control when the tests are being run?

@connectdotz
Copy link
Collaborator

interesting use case... just to make sure we are on the same page.

Are you concerning the initial full test run or the subsequent watch-mode run? The initial full test run can be turned off but not the watch-mode right now... In theory, the watch mode should only run the changed tests, which should be a smaller scope than the full run. Are you asking to turn off full and watch-mode all together and just have an "on-demand full test run" instead?

@jimmyzzxhlh
Copy link
Author

jimmyzzxhlh commented Aug 20, 2020

@connectdotz I'm more concerning about the subsequent watch-mode run. The initial full test run is OK since it's a one-time thing and it can be turned off. However for subsequent runs the problem is the cpu load will spike up every time I save something so it becomes kind of annoying. An on-demand test run would fit my need, but it'd be great if we have a way to just run the test for the current file being edited (Jest plugin in IntelliJ can run tests for one single file, or for just one test).

@connectdotz
Copy link
Collaborator

connectdotz commented Aug 22, 2020

I see... run tests in the current file or a specific test has been asked before... we haven't implemented it thinking that is a subset of watch-mode behavior. However, your point is that you don't want it to run for every save but on-demand instead. I can see this feature be useful to some use cases...

If anybody is interested in implementing the "on-demand mode" in addition to the watch-mode, I can work with you. We already have most pieces, so should not be too difficult...

@ifiokjr
Copy link

ifiokjr commented Sep 5, 2020

@connectdotz This is essential in my opinion.

Once the number of tests a certain number watch mode becomes unusable. Switched on, in a sufficiently large project, I'm restarting VS Code once or twice every hour.

As a result my current workflow is this.

  • Identify a broken test
  • Re-enable this plugin for the workspace.
  • Debug the broken test.
  • Disable this plugin for the workspace.

Watch mode as it currently is fails when working on any core file. An edit causes 90% of the tests to run.

For a real life example of this:

  • Clone https://github.com/remirror/remirror

     git clone https://github.com/remirror/remirror
  • Install dependencies with pnpm i - pnpm can be installed via npm i -g pnpm.

  • Open this file to edit packages/@remirror/core-helpers/src/core-helpers.ts

  • Add a few edits and save maybe 5 or 6 times.

  • Listen to the harmonious symphony of your machine's overworked fan.

@connectdotz
Copy link
Collaborator

@ifiokjr thanks for the test repo. I agree it will be nice to have an on-demand mode...

@jimmyzzxhlh and @ifiokjr, please let me know if the following workflow works for your use cases:

  • enable jest.onDemand or something like this in your config
  • when you open the project, the plugin will not run any test automatically
  • when you are ready to run tests, you can use the Command Palette (or maybe configure keyboard shortcut) to trigger jest full run (or your custom jest.pathToJest if configured)

@jimmyzzxhlh
Copy link
Author

@connectdotz Yes this works for me.

@MatheusPoliCamilo
Copy link

@jimmyzzxhlh how did you do this "onDemand" configuration?

@jimmyzzxhlh
Copy link
Author

@jimmyzzxhlh how did you do this "onDemand" configuration?

That doesn't exist, and it's exactly what I'm asking for here :)

@MatheusPoliCamilo
Copy link

Ah ok, you said it worked, I thought you found something hahah thanks!

@ematta
Copy link

ematta commented Dec 10, 2020

I tried to disabled:

"jest.autoEnable": false,
"jest.runAllTestsFirst": false,

and watchmode is still going crazy. It's making this plugin nearly unusable.

@rnewman
Copy link

rnewman commented Dec 19, 2020

I ended up turning off this plugin for this reason. Running tests in the Terminal isn't so bad…

@dave-vazquez
Copy link

Yeah, I've only been using this a day and this extension is very CPU intensive. I may have to uninstall this if there's no option to disable watch-mode sometime soon. Looking forward to this option being added.

@sldsrg
Copy link

sldsrg commented Feb 26, 2021

Strange that "jest.autoEnable": false, turns watch mode off, but "jest.runAllTestsFirst": false, ignores previous parameter and turns watch mode back on.

@connectdotz
Copy link
Collaborator

Hi, we have addressed this issue in v4.0.0-alpha.5, please feel free to give it a try and let us know if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants