A comprehensive experience when using Facebook's Jest within a project.
How to get it?
Simply open Jest - Visual Studio Marketplace and click "Install". Alternatively open Visual Studio Code, go to the extension view and search for "Jest".
For detailed releases and migration help, please see releases.
How to get it set up?
This extension runs on top of your Jest installation. Upon starting, it has the expectation that the Jest environment is properly set up, i.e. jest can be executed in VS Code's terminal.
Out of the box, this extension should work for most simple/standard jest and react projects. However, if you have a more sophisticated project or custom jest command, the default configuration most likely won't be sufficient but you can easily customize it with various settings*, such as
If you encountered any difficulty or have suggestions, please do not hesitate to ask, we have an active community that you might find helpful.
*: all settings in this extension are prefixed with
How to start Jest?
The extension will start Jest for you when:
How do I debug tests?
The simplest use cases should be supported out-of-the-box, but at the latest when VS Code displays errors about the attribute
This plugin provides blueprints for debugging plain Jest setups or projects bootstrapped by
Starting with debugging is possible by clicking on the
Notes for troubleshooting
In contrast to previous versions of this plugin the debug settings are now independent from VS Code's
How do I show code coverage?
Starting from v3.1, code coverage can be easily turned on/off at runtime without customization.
To toggle the coverage mode: go to Command Palette and select Jest: Toggle Coverage Overlay command. (TODO: toggle from StatusBar, PR welcome)
The coverage mode, along with watch mode, are shown in StatusBar:
(The initial coverage mode is
I'd like to give a shout out to Wallaby.js, which is a significantly more comprehensive and covers a lot more editors, if this extension interests you - check out that too.
Someone to take responsibility for ensuring that the default setup for create-react-app is always working. All the current authors use TypeScript and React/React Native and so have very little familiarity with changes to CRA. Apply via PRs :D.
start jest from non-root folder
If you don't use the root of your project for your JS with Jest tests, do not worry, you can still use this project. You will need to use the "Start Jest Runner" command, and maybe have to configure your own
These are the activation events which trigger the runner to start:
These are the things that will trigger the extension loading. If one of these applies, and you're not seeing the "Jest" in the bottom bar, reference the self-diagnosis below
use extension in multiroot environment
vscode-jest supports multiroot feature, but if you want to turn it off for some workspace folders check out
vscode-jest supports common jest configuration, such as when jest is in
However, if your repo doesn't fall into these patterns or you want to pass extra parameters, you can easily use the
plugin not running as expect? try self-diagnosis
If your can execute jest tests on command line but vscode-jest was not running as expected, here is what you can do to find out what it is actually doing:
Hopefully most issues would be pretty obvious after seeing these extra output, and you can probably fix most yourself by customizing the
Want to Contribute?
Thanks for considering! Check here for useful tips and guidelines.