Created
March 28, 2020 19:38
-
-
Save paigen11/33f07022cb425bb23be9386e4f343fa5 to your computer and use it in GitHub Desktop.
Sample code using screen to ID elements in the DOM instead of container or component with React Testing Library
This file contains hidden or 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
import React from 'react'; | |
import { screen } from '@testing-library/dom'; | |
import { render } from '@testing-library/react'; | |
import { act } from 'react-dom/test-utils'; | |
import App from './App'; | |
describe('Product Browser App', () => { | |
it('renders a welcome message', () => { | |
act(() => { | |
render(<App />); | |
}); | |
screen.findByText('Hello world'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment