I have some sets of Jest test cases that run Puppeteer browser tests.
I have tried these test runners
To me, I like Jest Test Explorer the most but it always auto-start running test cases. As you can imagine, a lot of Chrome browser instances get launched when I open a project with VS Code.
I found some configurations but they cannot prevent auto-run test cases.
"testExplorer.onStart": "reset"
, or set to null"testExplorer.onReload": "reset"
, or set to nullFYI, an example UI of Jest Test Explorer
Jest (vscode-jest
) is a good runner but I can't stop auto-run with these settings as well.
"jest.runAllTestsFirst": false,
"jest.autoEnable": false,
"jest.showCoverageOnLoad": false
Therefore, right now Jest Runner (vscode-jest-runner) is the only runner that does not auto-start unit tests.
In addition, if you have any other test runners to suggest, please let me know.
Thank you so much.
First open the jest extension settings.json in the vs code. In the json script add "jest.autoRun": "off"
to disable test autorun. Below, I add other options as well.
Source: Documentation
There's some great updated docs here
Migration rule from settings prior to v4:
if "jest.autoEnabled" = false => manual mode: "jest.autoRun": "off"
if "jest.runAllTestsFirst" = false => "jest.autoRun": {"watch": true }
if no customization of the 2 settings and no "jest.autoRun" found =>
I made it work by only setting the setting "jest.autoEnable": false,
on my settings.json
and restarting VSCode. At least, it is working until now and it hasn't broken yet: Disable starting Jest automatically
To open your settings.json
:
Preferences: Open Settings (JSON)
Go to vscode setting.json
You can either add
"jest.autoRun": "off"
or
"jest.autoRun": false
both are valid options. You can checkout the official recommended settings here.
https://github.com/jest-community/vscode-jest/blob/master/README.md#how-to-trigger-the-test-run
"jest.autoEnable": false
is deprecated.
I just set this simple option into the VS Code's settings.json
:
"jest.autoRun": "false"
autoEnable
should instead use autoRun
. invalid autoRun setting "false". Will use default setting instead
I'm now using the setting "jest.autoRun": { "watch": false }
instead For orta.vscode-jest
extension, I added the configuration below in settings.json
. You can open settings.json
by doing Command + Shift + P
(Ctrl + Shift + P on Windows), typing settings JSON
and selecting Preferences: Open Settings (JSON)
.
"jest.autoRun": {
"onStartup": []
}
Or you can simply add:
"jest.autoRun": {}
If you want to run all tests on startup, add all-tests
to the onStartup
array:
"jest.autoRun": {
"onStartup": ["all-tests"]
}
What it worked for me was:
File -> preferences -> settings. Then under the panel user (in workspace is as well but I am not sure if you need to modify it there as well), go to extensions -> jest.
There you will have a section jest: auto run and you will find a link "edit in settings.json" and modify what is there for this
"jest.autoRun": { "watch": false }
At the time of writing (Dec 22) the new way to do this (as per https://github.com/jest-community/vscode-jest/blob/master/README.md#how-to-trigger-the-test-run) is to have the following in the VS Code settings.json. Note I had previously tried the other answers but none worked.
"jest.autoRun": { "watch": false }