Loading Thucde.dev
Preparing the next view.
1 min read
Most of the cases, you don't need to, but for some, you do.
_app.tsx or _app.jsx file yet. I'll show you a way.@testing-library/react - a very famous one with over 7M weekly downloads.npm i @testing-library/react
Install @testing-library/react
npm, yarn, bun, pnpm._app.tsx or _app.jsx file, it should be something under the configured test location, such as __tests__/app/_app.test.tsx, and fill as follows:import { render, screen, waitFor } from '@testing-library/react'; import App from '@/app/_app'; describe('App', () => { it('test the App component', () => { // Act render(<App Component={() => <div>Test</div>} pageProps={{}} router={{} as any} />); // Assert waitFor(() => { expect(screen.getByText('Test')).toBeInTheDocument(); }); }); });
Test the _app component - App.