Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
512d342f
Unverified
Commit
512d342f
authored
Apr 21, 2024
by
Sebastian Silbermann
Committed by
GitHub
Apr 21, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update `@testing-library/react` used in tests (#64851)
Closes NEXT-3183
parent
aa126abb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
28 deletions
+29
-28
index.test.ts
test/production/jest/index.test.ts
+12
-10
new-link-behavior.test.ts
test/production/jest/new-link-behavior.test.ts
+6
-7
next-image-preload.test.ts
...uction/jest/next-image-preload/next-image-preload.test.ts
+3
-3
relay-jest.test.ts
test/production/jest/relay/relay-jest.test.ts
+3
-3
remove-react-properties-jest.test.ts
...ove-react-properties/remove-react-properties-jest.test.ts
+5
-5
No files found.
test/production/jest/index.test.ts
View file @
512d342f
...
@@ -76,17 +76,18 @@ describe('next/jest', () => {
...
@@ -76,17 +76,18 @@ describe('next/jest', () => {
describe("Home", () => {
describe("Home", () => {
it("renders a heading", () => {
it("renders a heading", () => {
act(() => {
const { unmount } = render(<Home />);
render(<Home />);
const heading = screen.getByRole("heading", {
const heading = screen.getByRole("heading", {
name: /Loading/i,
name: /Loading/i,
});
});
expect(heading).toBeInTheDocument();
expect(heading).toBeInTheDocument();
unmount();
});
});
});
});
});
`
,
`
,
'lib/hello.mjs'
:
`
'lib/hello.mjs'
:
`
import path from 'path'
import path from 'path'
...
@@ -128,10 +129,11 @@ describe('next/jest', () => {
...
@@ -128,10 +129,11 @@ describe('next/jest', () => {
},
},
dependencies
:
{
dependencies
:
{
'@next/font'
:
'canary'
,
'@next/font'
:
'canary'
,
jest
:
'27.4.7'
,
jest
:
'29.7.0'
,
'jest-environment-jsdom'
:
'29.7.0'
,
'@testing-library/jest-dom'
:
'5.16.1'
,
'@testing-library/jest-dom'
:
'5.16.1'
,
'@testing-library/react'
:
'1
2.1
.2'
,
'@testing-library/react'
:
'1
5.0
.2'
,
'@testing-library/user-event'
:
'1
3.5.0
'
,
'@testing-library/user-event'
:
'1
4.5.2
'
,
},
},
packageJson
:
{
packageJson
:
{
scripts
:
{
scripts
:
{
...
...
test/production/jest/new-link-behavior.test.ts
View file @
512d342f
...
@@ -19,13 +19,11 @@ describe('next/jest newLinkBehavior', () => {
...
@@ -19,13 +19,11 @@ describe('next/jest newLinkBehavior', () => {
import Page from '../pages/index'
import Page from '../pages/index'
it('Link', () => {
it('Link', () => {
act(() => {
render(<Page />)
render(<Page />)
const link = screen.getByRole('link', { name: 'Hello World!' })
const link = screen.getByRole('link', { name: 'Hello World!' })
expect(link.getAttribute('href')).toBe('https://example.com')
expect(link.getAttribute('href')).toBe('https://example.com')
})
})
})
`
,
`
,
'jest.config.js'
:
`
'jest.config.js'
:
`
const nextJest = require('next/jest')
const nextJest = require('next/jest')
...
@@ -36,8 +34,9 @@ describe('next/jest newLinkBehavior', () => {
...
@@ -36,8 +34,9 @@ describe('next/jest newLinkBehavior', () => {
`
,
`
,
},
},
dependencies
:
{
dependencies
:
{
jest
:
'27.4.7'
,
jest
:
'29.7.0'
,
'@testing-library/react'
:
'12.1.2'
,
'jest-environment-jsdom'
:
'29.7.0'
,
'@testing-library/react'
:
'15.0.2'
,
},
},
packageJson
:
{
packageJson
:
{
scripts
:
{
scripts
:
{
...
...
test/production/jest/next-image-preload/next-image-preload.test.ts
View file @
512d342f
...
@@ -26,9 +26,9 @@ describe('next/jest', () => {
...
@@ -26,9 +26,9 @@ describe('next/jest', () => {
'jest.config.js'
:
new
FileRef
(
path
.
join
(
appDir
,
'jest.config.js'
)),
'jest.config.js'
:
new
FileRef
(
path
.
join
(
appDir
,
'jest.config.js'
)),
},
},
dependencies
:
{
dependencies
:
{
jest
:
'29.
6.2
'
,
jest
:
'29.
7.0
'
,
'jest-environment-jsdom'
:
'29.
6.2
'
,
'jest-environment-jsdom'
:
'29.
7.0
'
,
'@testing-library/react'
:
'1
4.0.0
'
,
'@testing-library/react'
:
'1
5.0.2
'
,
'@testing-library/jest-dom'
:
'5.17.0'
,
'@testing-library/jest-dom'
:
'5.17.0'
,
},
},
})
})
...
...
test/production/jest/relay/relay-jest.test.ts
View file @
512d342f
...
@@ -13,7 +13,7 @@ describe('next/jest', () => {
...
@@ -13,7 +13,7 @@ describe('next/jest', () => {
components
:
new
FileRef
(
path
.
join
(
appDir
,
'components'
)),
components
:
new
FileRef
(
path
.
join
(
appDir
,
'components'
)),
pages
:
new
FileRef
(
path
.
join
(
appDir
,
'pages'
)),
pages
:
new
FileRef
(
path
.
join
(
appDir
,
'pages'
)),
'tests/entry.test.tsx'
:
`
'tests/entry.test.tsx'
:
`
import { render
as renderFn
, waitFor } from '@testing-library/react'
import { render, waitFor } from '@testing-library/react'
import { RelayEnvironmentProvider } from 'react-relay'
import { RelayEnvironmentProvider } from 'react-relay'
import { createMockEnvironment, MockPayloadGenerator } from 'relay-test-utils'
import { createMockEnvironment, MockPayloadGenerator } from 'relay-test-utils'
...
@@ -23,7 +23,7 @@ describe('next/jest', () => {
...
@@ -23,7 +23,7 @@ describe('next/jest', () => {
it('should work', async () => {
it('should work', async () => {
let environment = createMockEnvironment()
let environment = createMockEnvironment()
const { getByText } = render
Fn
(
const { getByText } = render(
<RelayEnvironmentProvider environment={environment}>
<RelayEnvironmentProvider environment={environment}>
<Page />
<Page />
</RelayEnvironmentProvider>
</RelayEnvironmentProvider>
...
@@ -49,7 +49,7 @@ describe('next/jest', () => {
...
@@ -49,7 +49,7 @@ describe('next/jest', () => {
dependencies
:
{
dependencies
:
{
jest
:
'27.4.7'
,
jest
:
'27.4.7'
,
'react-relay'
:
'13.2.0'
,
'react-relay'
:
'13.2.0'
,
'@testing-library/react'
:
'1
3.1.1
'
,
'@testing-library/react'
:
'1
5.0.2
'
,
'@types/jest'
:
'27.4.1'
,
'@types/jest'
:
'27.4.1'
,
'babel-jest'
:
'27.5.1'
,
'babel-jest'
:
'27.5.1'
,
'babel-plugin-relay'
:
'13.2.0'
,
'babel-plugin-relay'
:
'13.2.0'
,
...
...
test/production/jest/remove-react-properties/remove-react-properties-jest.test.ts
View file @
512d342f
...
@@ -13,14 +13,14 @@ describe('next/jest', () => {
...
@@ -13,14 +13,14 @@ describe('next/jest', () => {
files
:
{
files
:
{
pages
:
new
FileRef
(
path
.
join
(
appDir
,
'pages'
)),
pages
:
new
FileRef
(
path
.
join
(
appDir
,
'pages'
)),
'tests/index.test.tsx'
:
`
'tests/index.test.tsx'
:
`
import { render
as renderFn
, waitFor } from '@testing-library/react'
import { render, waitFor } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect';
import '@testing-library/jest-dom/extend-expect';
import Page from '@/pages'
import Page from '@/pages'
describe('testid', () => {
describe('testid', () => {
it('data-testid should be available in the test', async () => {
it('data-testid should be available in the test', async () => {
const { getByTestId } = render
Fn
(
const { getByTestId } = render(
<Page />
<Page />
)
)
expect(getByTestId('main-text')).toHaveTextContent('Hello World')
expect(getByTestId('main-text')).toHaveTextContent('Hello World')
...
@@ -33,9 +33,9 @@ describe('next/jest', () => {
...
@@ -33,9 +33,9 @@ describe('next/jest', () => {
'tsconfig.json'
:
new
FileRef
(
path
.
join
(
appDir
,
'tsconfig.json'
)),
'tsconfig.json'
:
new
FileRef
(
path
.
join
(
appDir
,
'tsconfig.json'
)),
},
},
dependencies
:
{
dependencies
:
{
jest
:
'2
7.4.7
'
,
jest
:
'2
9.7.0
'
,
'
@testing-library/react'
:
'^13.1.1
'
,
'
jest-environment-jsdom'
:
'29.7.0
'
,
jsdom
:
'^19.0.0
'
,
'@testing-library/react'
:
'15.0.2
'
,
'@testing-library/jest-dom'
:
'5.16.4'
,
'@testing-library/jest-dom'
:
'5.16.4'
,
},
},
packageJson
:
{
packageJson
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment