-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tests for page in App Router
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import About from './page'; | ||
|
||
// The easiest solution to mock `next/router`: https://github.com/vercel/next.js/issues/7479 | ||
// The mock has been moved to `__mocks__` folder to avoid duplication | ||
|
||
describe('About page', () => { | ||
describe('Render method', () => { | ||
it('should have two paragraphs of `Lorem ipsum`', () => { | ||
render(<About />); | ||
|
||
const paragraph = screen.getAllByText(/Lorem ipsum/); | ||
|
||
expect(paragraph).toHaveLength(2); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import Index from './page'; | ||
|
||
// The easiest solution to mock `next/router`: https://github.com/vercel/next.js/issues/7479 | ||
// The mock has been moved to `__mocks__` folder to avoid duplication | ||
|
||
describe('Index page', () => { | ||
describe('Render method', () => { | ||
it('should have h1 tag', () => { | ||
render(<Index />); | ||
|
||
const heading = screen.getByRole('heading', { | ||
name: /Boilerplate code/, | ||
}); | ||
|
||
expect(heading).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |