Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Completely disable auto run of Jest test runner in Visual Studio Code editor

I have some sets of Jest test cases that run Puppeteer browser tests.

I have tried these test runners

  • Jest (vscode-jest)
  • Jest Test Explorer (Jest Test Explorer for Visual Studio Code)
  • Jest Runner (vscode-jest-runner)

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 null

FYI, an example UI of Jest Test Explorer enter image description here

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.

like image 440
theeranitp Avatar asked Jul 21 '19 11:07

theeranitp


People also ask

How do I stop Jest test?

By default, Jest runs all your tests and shows their result in the console. Yet, Jest comes with a bail option allowing you to stop running tests after n failed tests. You may configure the bail option to a boolean value or a number. Using a boolean for bail will either stop or not stop after the first failed test.

What is the difference between jest-runner and VSCode-jest?

vscode-jest-runner is focused on running or debugging a specific test or test-suite, while vscode-jest is running your current test-suite everytime you change it. Simple way to run or debug a specific test As it is possible in IntelliJ / Webstorm Jest Runner will work out of the box, with a valid Jest config.

How to debug jest tests in VSCode?

Help debug jest tests in vscode. Supports multiple test run modes (automated, manual, and hybrid onSave) to meet user's preferred development experience. Simply open Jest - Visual Studio Marketplace and click "Install". Alternatively open Visual Studio Code, go to the extension view and search for "Jest".

How can I run tests differently with the jest extension?

If you have a more sophisticated project configuration or prefer to run tests differently, fear not, the extension supports extensive customization settings. For example: you can use jest.jestCommandLine to tell the extension to use yarn test instead of the default jest command.

Can I run unit tests in Visual Studio using JavaScript?

You can write and run unit tests in Visual Studio using some of the more popular JavaScript frameworks without the need to switch to a command prompt. Both Node.js and ASP.NET Core projects are supported. The supported frameworks are: Mocha (mochajs.org) Jasmine (Jasmine.github.io) Tape (github.com/substack/tape) Jest (jestjs.io)


1 Answers

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:

  1. Press Ctrl+Shift+P
  2. Then type Preferences: Open Settings (JSON)
like image 193
user Avatar answered Sep 20 '22 07:09

user