Running Jest in VS Code

Moses Gunesch
1 min readApr 7, 2017

--

There’s a nice Jest plugin for VS Code that adds green or red dots next to each test and even shows which lines fail with inline comments.

Unfortunately, at least at time of writing this, it’s sorely lacking the full interactive, syntax-highlighted goodness of jest --watch. Here’s a trick that makes it easy:

  1. Add a script to your package.json like:
"jest-w": "jest --watch",

2. Open the in-editor Terminal in VS Code (ctrl-`) and type yarn jest-w (or npm run jest-w).

That’s all!

jest watch running in the VS Code in-editor Terminal pane

When you run watch inside the editor, you get the added bonus that console.log shows up in the output for easy debugging. 💥

--

--

Moses Gunesch

Just another software engineering dad in Portland, Oregon