Toggle the .only modifier on the current test block with a single command.
Disable all other test blocks that have .only to ensure only one test is focused at a time.
Easily switch between running all tests and running only the focused test.
Supports popular testing frameworks: Jest, Vitest, Mocha, and Jasmine.
Customizable keyboard shortcuts for quick access.
Customization: Modify the focusModifier (default: '.only') and testIdentifiers (default: ['it', 'test', 'describe']) to match your testing framework's syntax.
Open Visual Studio Code.
Go to the Extensions view by clicking on the square icon in the left sidebar or pressing Ctrl+Shift+X.
Search for "Toggle Test .only" in the Extensions view search bar.
Click the "Install" button next to the extension authored by [Your Name].
Place the cursor inside a test block you want to focus on (e.g., an it, test, or describe block).
Use one of the following methods to toggle the .only modifier:
Open the command palette by pressing Ctrl+Shift+P.
Type "Toggle Only" and select the command.
Assign a custom keyboard shortcut to the "Toggle Test .only" command for quick access. To do this:
Open the Keyboard Shortcuts settings by pressing Ctrl+K Ctrl+S.
Search for "Toggle Only" in the search bar.
Right-click on the command and choose "Add Keybinding" to set your preferred shortcut.
The extension will toggle the .only modifier on the current test block, disabling all other test blocks that have .only, ensuring only one test is focused at a time. This allows you to run focused tests or revert to running all tests.
This extension provides a few configuration options to customize its behavior. You can access these settings by navigating to your VS Code settings (File > Preferences > Settings) and searching for "Toggle Test .only."
toggleTestOnly.focusModifier: Customize the modifier used to focus tests (e.g., change it from .only if your framework uses a different modifier).
toggleTestOnly.testIdentifiers: Customize the test block identifiers (e.g., change them to match your framework's syntax if needed). The default identifiers are ['it', 'test', 'describe'].
We welcome your feedback and contributions! If you encounter any issues, have suggestions, or want to contribute to the development of this extension, please visit the GitHub repository and create an issue or pull request.
About the Author
This extension is developed and maintained by omercohen990. Feel free to reach out to me with any questions or concerns.