Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for debugging jest tests in vscode #6034

Merged
merged 1 commit into from
Oct 31, 2018

Conversation

shiftkey
Copy link
Member

Overview

This PR re-adds support for being able to debug Desktop's unit tests inside VSCode.

There's two parts to supporting this in VSCode:

  • the node runtime to attach to - in this case we're using our local version of Electron
  • the program to run - we'll use jest with our existing unit test config

When you launch the tests, VSCode's terminal will appear and the rest of the experience looks familiar if you've run the tests from the command line:

But to see the real magic, set a breakpoint inside a test (the gutter to the left of the numbers) like this:

At some point after that, the tests should break on the breakpoint you just defined:

You then have access to the variables and stack trace in the left sidebar:

Description

In a nutshell, you now have two options:

  • Jest All to run all unit tests (the equivalent of yarn test:unit from the command line)
  • Jest Current to run all unit tests in the current file

I'd recommend Jest Current when working on tests, as that avoids running the whole test suite.

If you try and Jest Current from a file that doesn't contain any tests, you'll see an error like this:

You can set breakpoints anywhere in the code, but be careful where you Jest Current from.

I haven't had a chance to confirm this works the same on Windows, but I think it'll be fine...

Release notes

Notes: no-notes

@shiftkey shiftkey added ready-for-review Pull Requests that are ready to be reviewed by the maintainers infrastructure Issues and pull requests related to scripts and tooling for GitHub Desktop labels Oct 30, 2018
@outofambit
Copy link
Contributor

this works really nicely with https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest, too!

@outofambit outofambit self-assigned this Oct 30, 2018
@shiftkey
Copy link
Member Author

Gonna #jolo this in now so that I can use it for writing more tests 🎉

@shiftkey shiftkey merged commit 019b78d into master Oct 31, 2018
@shiftkey shiftkey deleted the bring-back-vscode-testing branch October 31, 2018 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Issues and pull requests related to scripts and tooling for GitHub Desktop ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants