Skip to content

bmalehorn/vscode-test-switcher

Repository files navigation

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
all *.* *.test.*
JavaScript / TypeScript *.* __tests__/*.test.*
JavaScript / TypeScript *.* test/*.test.*
JavaScript / TypeScript *.* test/suite/*.test.*
JavaScript / TypeScript *.* *.stories.*
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

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

About

Toggle between editing a file and its unit test, in any framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published