Testing Library Snippets (WIP)
The quick and easy way to create and use Testing Library with VS Code.
We also recommend installing his complement extension Vitest Snippets
Menu
Installation
Quick Launch
Open the quick launch with ctrl+shift+P (Win/Linux) or cmd+shift+P (macOS).
Paste the following command and press Enter
:
ext install deinsoftware.testing-library-snippets
Extension Manager
Open the extension manager with ctrl+shift+X (Win/Linux) or cmd+shift+X (macOS), search for Testing Library Snippets
and click on [Install]
button.
Marketplace
Supported Languages
Language | Extension |
---|---|
JavaScript | .js |
TypeScript | .ts |
JavaScript React | .jsx |
TypeScript React | .tsx |
Vue | .vue |
Snippets
Below is a list of all available snippets and the triggers of each one. The ░
means the TAB
jump position and █
the final cursor position.
Import
Trigger | Result |
---|---|
itl→ |
import { render, screen } from '@testing-library/░<react|vue>'█ |
itr→ |
import { render, screen } from '@testing-library/react'█ |
itv→ |
import { render, screen } from '@testing-library/vue'█ |
itrh→ |
import { renderHook } from '@testing-library/react'█ |
itue→ |
import user from '@testing-library/user-event'█ |
User Event
Trigger | Result |
---|---|
beus→ |
beforeEach(() => { |
Queries
Trigger | Result |
---|---|
gbr→ |
screen.getByRole('░id')█ |
gbro→ |
screen.getByRole('░id', {░})█ |
gbrc→ |
screen.getByRole('checkbox')█ |
gbrcc→ |
screen.getByRole('checkbox', { checked: ░<true|false>} })█ |
gbrh→ |
screen.getByRole('heading')█ |
gbrhl→ |
screen.getByRole('heading', { level: ░<1|2|3|4|5|6>} })█ |
gabr→ |
screen.getAllByRole('░id')█ |
gabro→ |
screen.getAllByRole('░id', {░})█ |
Debug
Trigger | Result |
---|---|
sd→ |
screen.debug()█ |
sltp→ |
screen.logTestingPlaygroundURL()█ |
Keyboard
Remember to complement the snippets with these keyboard shortcuts that can be used without needing to move the cursor to the start or to the end.
Action | Win/Linux | macOS |
---|---|---|
Insert line above | ctrl+shift+enter |
cmd+shift+enter |
Insert line below | ctrl+enter |
cmd+enter |
Settings
The editor.snippetSuggestions
setting in vscode settings.json
will show snippets on top of the suggestion list.
"editor.snippetSuggestions": "top"
About
Fork
- vscode-jest-snippets – Jest snippets extension for VS Code
Built With
- VS Code – Code editing redefined.
- Figma – The collaborative interface design tool.
- SWPM – One Package Manager to command them all.
Contributing
Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the Const & Props Snippets on GitHub.
Authors
- Camilo Martinez [Equiman]
See also the list of contributors who participated in this project.
Sponsors
If this project helps you, consider buying me a cup of coffee.
License
This project is licensed under the MIT License – see the LICENSE file for details.