As your test suite grows, finding one test among hundreds becomes slow. VS Code gives you filters, search, sort, and rerun commands that make a large Test Explorer manageable. This guide assumes you already know how to run and debug tests from the Test Explorer.
Filter tests by status
The filter dropdown in the Test Explorer toolbar (the funnel icon) has three preset filters:
- Show Only Failed Tests: Hides everything that passed. After a run with failures, this narrows the tree to only the tests you need to fix.
- Show Only Passed Tests: Hides failures and skipped tests.
- Show Tests for Current File: Shows only tests in the file you are actively editing. Useful when you are focused on one module.
Select a filter and the tree updates immediately. The filter stays active until you clear it by selecting Clear Filter from the same dropdown, or by clicking the funnel icon again.
When a filter is active, the toolbar run buttons apply only to the visible tests. So if you filter to Show Only Failed Tests and click Run All, only the failed tests rerun -- not the entire suite.
Search tests by name
Above the test tree is a search box. Start typing and the tree filters to match your text against test names. This works across every file in your project.
The search supports a special syntax. Type @status:failed to see only failed tests that also match your name search. You can combine this with any text: @status:failed login shows only failed tests with "login" in their name.
The search runs on every keystroke for small suites. For very large suites, there may be a brief pause. VS Code filters locally -- it does not rerun tests or query an external service.
Sort the test tree
By default, the Test Explorer shows tests in the same hierarchy as your file system. The More Actions menu (three dots in the toolbar) offers alternative sort orders:
- Sort by Duration: Orders tests from slowest to fastest based on the last run. Use this to find tests that take too long.
- Sort by Status: Groups failed tests at the top, then passed, then skipped.
- Sort by Location: The default file-system order.
You can also switch between Tree View (hierarchical, grouped by file and suite) and List View (flat, one test per row). List view works better with duration sorting because test names are not nested inside folder paths.
Rerun tests efficiently
After fixing a failing test, you need to rerun it to confirm the fix. Instead of finding it again in the tree, use one of these faster methods:
- Test: Rerun Last Run from the Command Palette. This reruns the exact set of tests you last executed, whether that was one test, a file, or the full suite.
- Rerun failed tests: Filter to Show Only Failed Tests, then click the toolbar run button. Clear the filter afterward.
- Rerun from editor: If the test file is still open, click the gutter play button next to the test. You never left the editor.
You can bind the Test: Rerun Last Run command to a keyboard shortcut. Open the Keyboard Shortcuts editor (Ctrl+K Ctrl+S on Windows/Linux, Cmd+K Cmd+S on macOS), search for Test: Rerun Last Run, and assign a key combination.
If you want to rerun tests automatically when you save a file, use your test runner's watch mode in the integrated terminal. Jest supports --watch, pytest has pytest-watch, and the Node.js test runner supports --watch. The Test Explorer updates its results whenever a watch-mode run finishes.
Organize the Test Explorer view
Right-click any test or group in the tree for context actions:
- Run, Debug, or Run with Coverage on that node.
- Collapse All to fold the entire tree.
- Hide Test to temporarily remove a test from the view. Hidden tests still run when you run the parent group. Use this for generated or data-driven tests you do not need to see.
In the More Actions menu, you can also toggle Show Source to highlight the test in the editor when you click it in the tree. This is on by default and helps you keep your place.
Handle large test suites
For projects with thousands of tests, additional strategies help:
- Use the Show Tests for Current File filter while you work on one module. Switch files and the tree updates automatically.
- Collapse all groups before searching. The tree filters faster when most nodes are collapsed.
- Disable the Show Source option in More Actions if clicking tests causes noticeable editor lag on your machine.
- Split tests into smaller run configurations and task groups so you can run subsets from the terminal instead of scrolling the tree.
Troubleshooting
The test count badge on the Activity Bar is distracting
The beaker icon shows a badge with the number of failed tests. If the constant reminder is stressful while you work on something else, click the Test Explorer and run the tests to confirm the failures. No setting hides only the badge while keeping the icon.
Searched tests do not show results from all files
The search looks at test names in the tree, which come from your test runner. If a file uses custom naming that the runner does not recognize, those tests may not appear in the tree at all. Run the Refresh Tests button to make sure discovery is current.
Sorting by duration shows all zeros
Duration sorting depends on the last run. If you cleared results or restarted VS Code, run the tests first so duration data is available.
Once you can filter and organize your tests, learn how to automate them with tasks.json so you can run tests without opening the Test Explorer.
Rune AI
Key Insights
- Use the filter dropdown (funnel icon) to show only failed tests, only passed tests, or only tests in the currently open file.
- Use the search box to find tests by name instantly. Type @status:failed to filter by status directly in the search.
- Sort by Duration in the More Actions menu to find slow tests that may need optimization.
- Rerun only failed tests: filter to Show Only Failed Tests, then click Run.
- Use Test: Rerun Last Run from the Command Palette to rerun the previous test set without finding it in the tree.
Frequently Asked Questions
Can I run only failed tests without touching the tree?
How do I search for a specific test by name?
Can I sort tests instead of seeing them by file structure?
How do I rerun the last test I just edited?
Conclusion
The Test Explorer handles large test suites with filtering, search, and sort tools. Filter by status to focus on failures, search by name to find one specific test, and sort by duration to spot slow tests. Use the Rerun Last Run command to save time when you are iterating on a fix. After you master test organization, set up tasks.json to automate your test runs.
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.