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

How to disable annoyingly terminal pop up on launch #973

Closed
KevinYobeth opened this issue Dec 23, 2022 · 20 comments · Fixed by #976 or #985
Closed

How to disable annoyingly terminal pop up on launch #973

KevinYobeth opened this issue Dec 23, 2022 · 20 comments · Fixed by #976 or #985

Comments

@KevinYobeth
Copy link

Environment

  1. vscode-jest version: v5.1.0
  2. node -v: v14.18.2
  3. npm -v or yarn --version: 6.14.15
  4. npm ls jest or npm ls react-scripts (if you haven’t ejected): └── jest@27.5.1
  5. your vscode-jest settings if customized:
    • jest.autoRun? false
  6. Operating system: Windows 11

Prerequisite

  • are you able to run jest test from the command line? yes
  • how do you run your tests from the command line? (for example: npm run test or node_modules/.bin/jest) npm run test

Steps to Reproduce

  1. Open projects in vscode

Relevant Debug Info

image
This is so annoying, when opening a project, it automatically start a new terminal logging the auto config. I don't want this behavior, how to disable terminal automatically popping up?

Expected Behavior

Terminal not popping up on every launch, instead only launch when tests runner are clicked.

Actual Behavior

Terminal annoyingly pop up on every launch.


The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR...

@yunnysunny
Copy link

I have set "jest.autoRun": "off" in my settings.json ,but it doesn't work.

@connectdotz
Copy link
Collaborator

I think defer output till the actual run is a good idea!

@connectdotz
Copy link
Collaborator

connectdotz commented Dec 23, 2022

Here is the change I am currently thinking:
Create a new setting jest.revealOutput that can be "on-run" or "silent":

  • jest.revealOutput: "on-run" (the default):
    • create a background terminal when the actual jest run starts, which will be impacted by the jest.autoRun setting.
  • jest.revealOutput: "silent":
    • terminal will not be created unless one of the trigger events (below) happens.

The trigger events to create and bring terminal to the foreground (apply to all jest.revealOutput setting):

  • if encountered "fatal" errors that prevented jest to start, for example
  • user clicking on the jest status bar item on the bottom of the screen

Note, the silent mode could mask issues such as an unintended jest process running in the background.

(see some explanation about background/foreground terminal here)

@pot-code
Copy link

They had a setting to disable it, but removed in new version.

@connectdotz
Copy link
Collaborator

connectdotz commented Dec 24, 2022

Ok, I have a prototype fix now (what could be a better use of Christmas eve 🤣 ). Giving we have many enthusiastic users here, I hope you guys can help us test it:

  1. unzip and install the extension patch vscode-jest-5.1.0.vsix.zip
  2. add "jest.revealOutput": "silent" to your settings.json file
  3. reload the window

Play around with it, and let me know how it works. Thanks.

@rangedsp
Copy link

rangedsp commented Jan 3, 2023

@connectdotz I tried the new build but the terminal is still popping up:
image

Settings:
image
image

The jest.config above is an empty file, but the terminal also pops up when I tried it in a client's project with valid jest config.

@connectdotz
Copy link
Collaborator

@rangedsp the terminal will always be shown if there is a fatal error, such as when jest can not be started like the one above. If there is no fatal error, the terminal should not be shown, assuming your terminal is not already opened. Let me know if you still have a problem.

@rangedsp
Copy link

rangedsp commented Jan 4, 2023

@connectdotz I can understand why errors prompt the terminal to show up, though in this case I am setting it to autoRun 'off' and revealOutput to be 'silence'. I.e. the intent is for jest to not do anything in the background.

May I suggest another level of 'revealOutput' that also prevents fatal errors from showing up?

@KevinYobeth
Copy link
Author

@connectdotz
May I suggest another level of 'revealOutput' that also prevents fatal errors from showing up?

I agree, there should be an option to completely disable jest terminal prompts

@connectdotz
Copy link
Collaborator

connectdotz commented Jan 4, 2023

Please help me understand why you don't want to know the fatal error if your goal is to run jest tests...

though in this case I am setting it to autoRun 'off' and revealOutput to be 'silence'. I.e. the intent is for jest to not do anything in the background.

When the extension starts up, before it can run jest, it will examine your environment, checking jest commands and counting test files as part of the extension setting up process. It's during this stage that it discovers the error you saw. Hiding the terminal does not stop the setup process; it only masks what really happened...

If your environment is not ready for jest yet, maybe what you are asking is to "disable" the extension, not just the terminal? What did I miss?

@rangedsp
Copy link

rangedsp commented Jan 5, 2023

When the extension starts up, before it can run jest, it will examine your environment, checking jest commands and counting test files as part of the extension setting up process. It's during this stage that it discovers the error you saw. Hiding the terminal does not stop the setup process; it only masks what really happened...

I have many workspaces, some with jest tests, some mainly C#, and quite a few others. That's why I turned off autoRun: I want to not know the extension jest even exists until I go into the testing tab and hit run. At that point, if a fatal error occurs it absolutely should be shown.

Yes, I do disable the extension every once in a while, but having to toggle it on/off and having to reload the window is a pain.

This seems to be in-line with what's in the OP's 'expected behavior':

Terminal ... only launch when tests runner are clicked.

Perhaps this is out of scope for this thread, but I'm curious to know why jest setup needs to be run on startup, as opposed to running it when you click on the testing tab? I played around with a couple of extensions I use a lot, (Docker, SQLTools, and Azure), and they only start enumerating resources when I click open their respective tabs.

@janaagaard75
Copy link

janaagaard75 commented Jan 5, 2023

Please help me understand why you don't want to know the fatal error if your goal is to run jest tests.

When I am rebasing my branch or making search-and-replace changes or other refactorizations, it's not that uncommon that the code is in a temporary state where some of the tests don't pass. I know why this happens. I use the Jest field in the status bar to confirm this, and confirm that everything is once again okay. So for me it's annoying that the terminal window opens up. I would like to be able to tell Jest to never open up the terminal automatically. I will do so with the item in the status bar, when I need it.

@connectdotz
Copy link
Collaborator

connectdotz commented Jan 8, 2023

thanks for the feedback!

@rangedsp

I have many workspaces, some with jest tests, some mainly C#, and quite a few others. That's why I turned off autoRun: I want to not know the extension jest even exists until I go into the testing tab and hit run. At that point, if a fatal error occurs it absolutely should be shown.

This pointing to the activation problem. The extension should not be activated for C# or other non-js/ts related projects. In 5.0 we switched to deep activation, which seems to bring in some unexpected mixed language dependency issues that I will look into next. I think once we resolve it, many of the apparent terminal issues would go away.

but I'm curious to know why jest setup needs to be run on startup, as opposed to running it when you click on the testing tab?
Users do not need to open the test tab to run tests, either automatically on startup (watch mode), or manually clicking on the editor's gutter icon. Even in manual mode, for the test files to show up in the test explorer or editor gutter status, we need to know what are the test files and parse the test files for test blocks. Therefore, there will be some setup ahead of time and there is no clear "trigger" point that we can safely delay the setup for all use cases.

@janaagaard75
What you describe is a transient stage for the project. I can see this but thought this should happen only rarely for a given project, so shouldn't be a problem, considering the trade-off of not seeing the fatal errors... but realized that maybe others would have different preferences... 🤔

Ok, based on all these feedbacks, I will make the following changes:

  1. change the setting to jest.autoRevealOutput: 'on-run' | 'on-exec-error' | 'off'
  2. need to reflect "fatal error" in the status bar, so the error is not lost even if the autoRevealOutput is "off"
  3. add a new issue to investigate how to prevent mix-project activation

@connectdotz
Copy link
Collaborator

ok, submitted the update, here is a new vsix, feel free to give it a try (note the setting name and value change, see above)

vscode-jest-5.1.0.vsix.zip

@connectdotz
Copy link
Collaborator

Hi, the fix jest.autoRevealOutput is released in 5.2.0 pre-release; feel free to give it a try and let us know if there is any issue.

@KevinYobeth
Copy link
Author

I've tested the pre-release version and it works flawlessly. Thank you very much @connectdotz!

@benevbright
Copy link

oh Lord.. how to stop it from opening terminal popup on launch?

  "jest.autoRun": "off",
  "jest.autoRevealOutput": "on-run",

I expect to see it only popup on my manual run, but it opens the terminal on launch.

@KevinYobeth
Copy link
Author

@benevbright change jest.autoRevealOutput to off

  "jest.autoRun": "off",
  "jest.autoRevealOutput": "off",

@EvgeniiaVak
Copy link

EvgeniiaVak commented Nov 10, 2023

In new version of Code Insiders there is another, more general setting setting (in settings.json):

"testing.openTesting": "neverOpen"

@sh-pq
Copy link

sh-pq commented Feb 15, 2024

In case you are here because of the February 2024 update to VS Code, see this newer issue:

The current resolution is to apply the following configuration to your preferences, as mentioned above and by connectdotz:

"testing.openTesting": "neverOpen"

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