This is the section of my VS Code User Preferences settings.json
(to access, Ctrl +P
then select Preferences: Open User Settings
) for Jest VS Code extension:
{
...
"jest.coverageFormatter": "GutterFormatter",
"jest.debugCodeLens.showWhenTestStateIn": [
"fail",
"unknown",
"pass",
"skip"
]
}
I found that the Jest extension's Debug CodeLens wouldn't always appear on tests. A lot of the time I had to go to Testing window in VS Code sidebar to start debugging on a test because the Debug codelens wasn't available on the test in situ in the code file.
Turns out this was because jest.debugCodeLens.showWhenTestStateIn
has default value of ["fail", "unknown"]
.
I added the other two possible statuses to ensure that the Debug codelens is always available.
The other setting here is jest.coverageFormatter
. I find seeing coverage in the gutter on the left of a file unobtrusive compared to the extension's default behaviour of colour-coding regions of code in the file.
You can of course set the above on a per project basis by putting the snippet above in .vscode\settings.json
in your workspace (this file can be created/navigated to using the command Ctrl + P
then Preferences: Open Workspace Settings
).