Docs are outdated about initial App.test.js

Posted 1 month ago

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

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 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);

[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]

Created 1 month ago

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