Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Test SwitcherNew to Visual Studio Code? Get it now.
Test Switcher

Test Switcher

Brian Malehorn

|
1,623 installs
| (2) | Free
Toggle between editing a file and its unit test
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Test Switcher

version number install count

Switch between a file and its unit test:

demo

On MacOS, press Shift+Cmd+Y.

On Windows / Linux, press Shift+Ctrl+Y.

The following formats are supported:

framework application file unit test file
JavaScript / TypeScript *.js † __tests__/*.test.js
JavaScript / TypeScript *.js † test/*.test.js
JavaScript / TypeScript *.js † test/suite/*.test.js
JavaScript / TypeScript *.js † *.test.js
Python *.py test/test_*.py
Python src/*/*.py test/*/test_*.py
Go *.go *_test.go
Ruby on Rails 1-5 app/*/*.rb spec/*/*_spec.rb
Ruby on Rails 6+ app/*/*.rb test/*/*_test.rb
Ruby minitest app/*.rb test/unit/*_test.rb
Ruby minitest app/controllers/*.rb test/integration/*.rb

† Also supports .jsx, .ts, .tsx.

Extension Settings

You can add your own formats by editing test-switcher.rules.

Here's what it would look like to add Ruby on Rails support:

"test-switcher.rules": [
  { "pattern": "app/(.*)\\.rb", "replacement": "spec/$1_spec.rb" },
  { "pattern": "spec/(.*)_spec\\.rb", "replacement": "app/$1.rb" },
]

Effectively, this extension runs path.replace(new RegExp(pattern), replacement). If the source file matches the regex the replaced filename exists, you'll switch to that file. Otherwise, it will try the next rule.

Release Notes

See CHANGELOG.md.

Similar Projects

  • Rails Go to Spec
  • File Switcher
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft