Testing with Jest, Vitest & Pytest
VS Code's Test Explorer provides a unified UI for running, debugging, and viewing the results of any test framework. This lesson covers Jest, Vitest, and Pytest integrations.
1The Test Explorer
Click the flask icon in the Activity Bar or press Ctrl+Shift+P → Testing: Focus on Test Explorer View. Once a test extension is installed and configured, all your tests appear here as a tree you can run, debug, or watch individually.
2Jest Setup
npm install -D jest @types/jest ts-jest npx ts-jest config:init
Install the Jest Runner or Jest (official) extension. Tests appear in the Test Explorer with run/debug buttons inline beside each test in the editor.
3Vitest Setup
npm install -D vitest # Add to package.json scripts: "test": "vitest"
Install the Vitest extension. It's faster than Jest and requires near-zero config for Vite projects.
4Pytest Setup
With the Python extension installed, it detects pytest automatically. Select your test framework: Ctrl+Shift+P → Python: Configure Tests. Tests show inline run buttons and a full Test Explorer tree.
5Debugging a Failing Test
Click the debug icon next to any failing test in the Test Explorer or inline in the editor to debug it with full breakpoint support. This is the fastest way to understand why a test fails.