RFC: React 19 support
@testing-library/react behaves differently when dealing with Suspense in React 18 and React 19
reactjs - Trying to create react app with React v19.0.0 but getting error - Stack Overflow
reactjs - React Testing Library gives console error for ReactDOM.render in React 18 - Stack Overflow
Videos
» npm install @testing-library/react
To solve the react testing library error:
"ReactDOM.render is no longer supported in React 18, update the version of the react testing library."
Open your terminal in the root directory of your project and run the following commands:
npm install --save-dev @testing-library/react@latest
npm install --save-dev @testing-library/jest-dom@latest
npm install --save-dev @testing-library/user-event@latest
Make sure to update the versions of all react testing library packages you are using.
Your index.js file should use the new createRoot API to render your application.
index.js
import React from 'react';
import ReactDOM from "react-dom/client";
import App from './App';
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
Now you should be able to start your tests without getting the error.
App.test.js
import {render, screen} from '@testing-library/react';
import App from './App';
test('renders react component', () => {
render(<App />);
const divElement = screen.getByText(/hello world/i);
expect(divElement).toBeInTheDocument();
});
uninstall @testing-library/react-hook and import renderHook from @testing-library/react
import { renderHook } from "@testing-library/react";
see here https://github.com/testing-library/react-hooks-testing-library/issues/826#issuecomment-1100650242
» npm install @testing-library/react-native
Hey everyone,
I have a react project where i added storybook for UI visual testing/documentation of the components and all.
I was wondering what is the best React testing library out there? best in terms of future proof, interaction testing, components testing, functions and all? I am hearing Jest here and there, but i would like to know the opinions of experts in this subject. Thanks in Advanced 🙏