Created
December 7, 2020 09:01
-
-
Save ChrisLowe-Takor/1b5f9a902ca72ba5f614a9cd6dc530a4 to your computer and use it in GitHub Desktop.
React test snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
"React test": { | |
"prefix": "rtest", | |
"body": [ | |
"import * as React from 'react';", | |
"import { createStore } from 'redux';", | |
"import { render, screen } from '@testing-library/react';", | |
"import '@testing-library/jest-dom/extend-expect';", | |
"", | |
"import { Provider } from 'react-redux';", | |
"import { state } from '../../../../store/root-reducer';", | |
"", | |
"import $1 from './${TM_FILENAME/\\.test\\.tsx$|/${1}${2}/g}';", | |
"", | |
"//", | |
"// yarn test ${TM_DIRECTORY/.*(?=src)/$1/}/${TM_FILENAME} --coverage --collectCoverageOnlyFrom=${TM_DIRECTORY/.*(?=src)/$1/}/${TM_FILENAME/\\.test\\.tsx$|/${1}${2}/g}.tsx", | |
"//", | |
"describe('$1 Component', () => {", | |
"", | |
" it('Mounts the component', () => {", | |
" const store = createStore(state);", | |
" render(", | |
" <Provider store={store}>", | |
" <$1 />", | |
" </Provider>", | |
" );", | |
"", | |
" console.log(screen.logTestingPlaygroundURL());", | |
" //expect(screen.queryByRole('heading', { name: /my title/i })).toBeInTheDocument();", | |
" });", | |
"});" | |
], | |
"description": "React test" | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment