Running tests in VS Code takes one click. Debugging a failing test takes two. The Testing view gives you play buttons, debug controls, and inline results that let you fix problems without switching to a terminal window.
This guide assumes you already have the Testing view open and tests discovered in your project. If not, start with setting up the Testing view and Test Explorer.
Run tests from three places
VS Code gives you three ways to trigger a test run, all equally fast.
The Test Explorer shows a play button next to every node. Click the play button in the toolbar to run all tests. Click the play button next to a file, group, or individual test to run just that subset.
The editor gutter shows a play icon next to each test function. Click it to run that single test. The icon appears when your cursor is on or near the test definition. Right-click the gutter icon to see additional actions, including debug and run with coverage.
The Command Palette has a Test: Run All Tests command and a Test: Run Tests in Current File command. These are useful when you prefer keyboard shortcuts or want to bind a custom key to test runs.
While tests run, play buttons turn into spinners. When the run finishes, each node updates with its result. The toolbar shows a summary: how many passed, failed, and skipped.
Read test results
Test results appear in two places at once.
The Test Explorer tree updates every node with a green check or red X. Expand a failed group to see exactly which test failed. The tree keeps the last result visible even after you close and reopen the Testing view.
The editor gutter shows a green check mark next to each passed test function and a red X next to each failed one. Hover over the red X to read the error message without opening any panel.
For full output, click the Show Output button in the Test Explorer toolbar (the terminal icon with lines). This opens the Test Results panel, which shows everything the test runner printed: console logs, assertion error details, and full stack traces. Each run creates a new tab, so you can keep a failed run open while you fix and rerun.
Debug a test
Debugging a test works exactly like debugging application code. The same debug toolbar, breakpoints, and variable inspection you use for your app are available inside test functions.
To debug a test, right-click it in the Test Explorer and select Debug Test. Or in the editor, right-click inside the test function and choose Debug Test. The gutter play button also has a debug option: right-click it instead of left-clicking.
VS Code starts a debug session. The Status Bar turns orange. If you set a breakpoint inside the test by clicking in the left gutter (or pressing F9), execution pauses on that line. The yellow highlight shows where the debugger stopped.
Now you can:
- Hover over variables to see their current values at the point of failure.
- Open the VARIABLES section in the Run and Debug view to browse all local and closure variables.
- Use the debug toolbar: Continue (F5), Step Over (F10), Step Into (F11), and Stop (Shift+F5).
- Type expressions in the Debug Console to evaluate values while paused.
This is the fastest way to understand a failing test. Instead of adding console.log statements and rerunning, set a breakpoint on the line before the failure and inspect the state directly.
Debug a test that passes but behaves unexpectedly
Sometimes a test passes but the logic is wrong. Set a breakpoint inside the passing test, right-click and choose Debug Test, and step through line by line. Watch your variables change in the VARIABLES section and confirm each step matches your expectations.
For tests with setup code (hooks, fixtures, before/after blocks), the debugger steps through those as well. You can set breakpoints in beforeEach or setup functions to inspect the state before your test body runs.
Fix a failing test with Copilot
VS Code has a built-in way to get AI help with failing tests. In the Test Explorer, hover over a failed test. A sparkle icon appears labeled Fix Test Failure. Click it.
Copilot reads the failure message and the test code, then suggests a fix in the editor. You can accept the suggestion, refine it with a follow-up prompt, or dismiss it.
You can also open Copilot Chat (Ctrl+Shift+I on Windows/Linux, Cmd+Shift+I on macOS) and type /fixTestFailure to get the same help.
Copilot can also generate tests for code that has none. Open the file you want to test, right-click in the editor, and select Copilot > Generate Tests. This is covered in the Testing view guide.
Run tests on save or file change
You can set up a test task to run automatically when files change, but the simplest approach is to use your test runner's watch mode.
For Jest: npx jest --watch in the integrated terminal.
For pytest with pytest-watch: ptw in the terminal.
For the Node.js test runner: node --test --watch in the terminal.
The watch mode runs affected tests whenever you save a file. The Test Explorer updates automatically when a watch-mode test run finishes, so you see the results both in the terminal and in the UI.
Troubleshooting
Debug Test does nothing or shows no debugger
Make sure you have a debugger extension installed for your language. The built-in Node.js debugger handles JavaScript and TypeScript tests. For Python, you need the Python extension.
For Java, the Test Runner for Java includes a debugger. If you are unsure, press F5 on a regular file to confirm debugging works at all.
The test passes even though I set a breakpoint
You are probably running the test instead of debugging it. Left-clicking the gutter play button runs the test without debugging. Right-click it and select Debug Test, or use the debug icon (bug with play) in the Test Explorer.
Copilot says it cannot fix the test
Copilot needs the test failure message and the test code to suggest a fix. Make sure you ran the test at least once so the failure output is available. If you still get no suggestion, open Copilot Chat, type /fixTestFailure, and paste the error message manually.
Once you can run and debug tests confidently, learn how test coverage shows exactly which lines your tests touch.
Rune AI
Key Insights
- Click the play button next to any test in the Test Explorer or editor gutter to run it. Right-click and choose Debug Test to debug it.
- Set a breakpoint inside your test function by clicking in the left gutter or pressing F9. The debugger pauses there when you debug the test.
- The debug toolbar (Continue F5, Step Over F10, Step Into F11, Stop Shift+F5) works the same way for tests as it does for application code.
- The Test Results panel shows full output from each test run, including console logs and stack traces.
- Hover over a failed test in the Test Explorer and click the sparkle icon to ask Copilot to fix it.
Frequently Asked Questions
How do I debug a single test instead of the whole file?
Can I set breakpoints in test code just like regular code?
How do I fix a failing test with Copilot?
The debug toolbar does not appear when I debug a test. Why?
Conclusion
Running tests from the Test Explorer or editor gutter is fast. Debugging tests gives you the same breakpoint, variable inspection, and step controls you use for application code. When a test fails, right-click it and choose Debug Test to pause at the exact line that broke. Use the Test Results panel to read full output, and let Copilot suggest a fix when you are stuck.
More in this topic
How to Use VS Code with WSL 2 on Windows
Run VS Code connected to Windows Subsystem for Linux so you can develop in a full Linux environment with native tools, terminals, and debugging, all from Windows.
20 Best VS Code Extensions for Web Developers in 2026
Twenty carefully chosen VS Code extensions every web developer should know. Covers formatting, linting, frameworks, debugging, Git, and developer experience.
How to Install, Disable, Update, and Uninstall VS Code Extensions
Learn how to install, disable, update, and uninstall VS Code extensions from the Marketplace and the command line. Step-by-step instructions for every action.