Skip to content

Update testing-library packages for cra-template #8699

Closed
@kentcdodds

Description

@kentcdodds

Describe the bug

The following package.json files need dependencies updated:

And the template code should be changed to use screen:

https://github.com/facebook/create-react-app/blob/8a1ee2f7a531d83cb76cc882d1e346c5cdd55f56/packages/cra-template-typescript/template/src/App.test.tsx

  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:

https://github.com/facebook/create-react-app/blob/2de57fe15a69a84fadb08ce549599c7de5a9d3b2/packages/cra-template/template/src/App.test.js

I think the rest of the template is irrelevant.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions