Skip to content

Instantly share code, notes, and snippets.

@IliasDeros
Last active May 13, 2022 14:26
Show Gist options
  • Save IliasDeros/3d49d48b9472030ef784ef09228ed499 to your computer and use it in GitHub Desktop.
Save IliasDeros/3d49d48b9472030ef784ef09228ed499 to your computer and use it in GitHub Desktop.
VSCode snippets. Add them in Preferences: Configure User snippets > typescriptreact.json
{
"React component test": {
"prefix": "react_test",
"body": [
"import React from 'react'",
"import { render } from '@testing-library/react'",
"import { $1 } from '../$1'",
"",
"describe('$1', () => {",
" let props",
"",
" beforeEach(() => {",
" props = {",
" ",
" }",
" })",
"",
" it('renders', () => {",
" const { container } = render(<$1 {...props} />)",
" expect(container).toBeTruthy()",
" })",
"})"
],
"description": "Scaffold a test using react testing-library"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment