Reputation: 1235
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.
Upvotes: 100
Views: 85172
Reputation: 371
as of 2024
"jest.autoRun": "off",
"jest.autoRevealOutput": "off"
are deprecated, use instead:
"jest.runMode": "on-demand"
you can change the global settings.json
or per project .vscode/settings.json
Upvotes: 5
Reputation: 101
"jest.autoRun": "off",
"jest.autoRevealOutput": "off",
These are deprecated add the line below
"jest.runMode": "on-demand",
Upvotes: 7
Reputation: 359
Just put this in settings.json (User)
"jest.runMode": "on-demand",
Upvotes: 27
Reputation: 2139
2024 update:
jest.autoRun
became deprecated, use "jest.runMode": "on-demand"
instead.
Upvotes: 23
Reputation: 11
Add this to settings.json:
"jest.autoRun": "off",
"jest.autoRevealOutput": "off",
Source: https://github.com/jest-community/vscode-jest/blob/master/README.md#settings
Upvotes: 0
Reputation: 1782
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 User 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"]
}
Upvotes: 81
Reputation: 61
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
}
Upvotes: 6
Reputation: 281
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 }
Upvotes: 28
Reputation: 745
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.
Upvotes: 8
Reputation:
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
Upvotes: 5
Reputation: 447
I just set this simple option into the VS Code's settings.json
:
"jest.autoRun": "false"
Upvotes: 33
Reputation: 91
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 =>
Upvotes: 5
Reputation: 9428
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)
Upvotes: 22