Skip to content

Commit e15ee02

Browse files
committed
add test debugging section to CONTRIBUTING.md
1 parent a209ce9 commit e15ee02

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ Running tests works the same way as building - running `yarn test` at the projec
4747

4848
Note: you must run `yarn build` before `yarn test` will work.
4949

50+
## Debugging Tests
51+
52+
If you run into trouble writing tests and need to debug one of them, you can do so using VSCode's debugger.
53+
54+
0. If you don't already have it installed, install the Tasks Shell Input extension, which you'll find in the Extensions tab in the sidebar as one of the recommended workspace extensions.
55+
56+
1. Place breakpoints or `debugger` statements in the test or the underlying code wherever you'd like `jest` to pause.
57+
2. Open the file containing the test in question, and make sure its tab is active (so you can see the file's contents).
58+
3. Switch to the debugger in the sidebar and choose `Debug unit tests - just open file` from the dropdown.
59+
4. Click the green "play" button to run the tests in the open file in watch mode.
60+
61+
Pro tip: If any of your breakpoints are in code run by multiple tests, and you run the whole test file, you'll land on those breakpoints over and over again, in the middle of tests you don't care about. To avoid this, replace the test's initial `it` or `test` with `it.only` or `test.only`. That way, when you hit a breakpoint, you'll know you got there are part of the buggy test.
62+
5063
## Linting
5164

5265
Similar to building and testing, linting can be done in the project root or in individual packages by calling `yarn lint`.

0 commit comments

Comments
 (0)