forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add @testing-library support to the default template
Closes facebook#6358
- Loading branch information
Kent C. Dodds
committed
Oct 25, 2019
1 parent
07ccad7
commit 033a41c
Showing
3 changed files
with
16 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { render } from '@testing-library/react'; | ||
import App from './App'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<App />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
test('renders welcome heading', () => { | ||
const { getByRole } = render(<App />); | ||
const headingElement = getByRole('heading'); | ||
expect(headingElement).toHaveTextContent(/welcome/i); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
// allows you to do things like: | ||
// expect(element).toHaveTextContent(/react/i) | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom/extend-expect' |