Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs are outdated about initial App.test.js #11548

Open
Gaelan opened this issue Oct 13, 2021 · 2 comments
Open

Docs are outdated about initial App.test.js #11548

Gaelan opened this issue Oct 13, 2021 · 2 comments

Comments

@Gaelan
Copy link

Gaelan commented Oct 13, 2021

Describe the bug

The "Running Tests" documentation currently says:

If you haven’t decided on a testing strategy yet, we recommend that you start with creating basic smoke tests for your components:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
 const div = document.createElement('div');
 ReactDOM.render(<App />, div);
});

This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot of value with very little effort so they are great as a starting point, and this is the test you will find in src/App.test.js.

This is no longer the case; since #7881 in 2019, the default test is a more comprehensive test that inspects the rendered output:

test('renders learn react link', () => {
  render(<App />);
  const linkElement = screen.getByText(/learn react/i);
  expect(linkElement).toBeInTheDocument();
});

[I've taken the liberty of removing the rest of the issue template - this is an issue with the docs, so the troubleshooting and reproduction stuff doesn't really apply]

@petetnt
Copy link
Contributor

petetnt commented Oct 14, 2021

Hi! Can you file a PR for updating the docs, that would be great 👍

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants