Update testing-library packages for cra-template
Created by: kentcdodds
Describe the bug
The following package.json files need dependencies updated:
- https://github.com/facebook/create-react-app/blob/94932bedc09976aeac43615d95906aa2dcfefa1f/packages/cra-template/template.json
- https://github.com/facebook/create-react-app/blob/94932bedc09976aeac43615d95906aa2dcfefa1f/packages/cra-template-typescript/template.json
And the template code should be changed to use screen
:
import React from 'react';
- import { render } from '@testing-library/react';
+ import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
- const { getByText } = render(<App />);
- const linkElement = getByText(/learn react/i);
+ render(<App />);
+ const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
And the same treatment for this one:
I think the rest of the template is irrelevant.