Unverified Commit 512d342f authored by Sebastian Silbermann's avatar Sebastian Silbermann Committed by GitHub

Update `@testing-library/react` used in tests (#64851)

Closes NEXT-3183
parent aa126abb
...@@ -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': '12.1.2', '@testing-library/react': '15.0.2',
'@testing-library/user-event': '13.5.0', '@testing-library/user-event': '14.5.2',
}, },
packageJson: { packageJson: {
scripts: { scripts: {
......
...@@ -19,12 +19,10 @@ describe('next/jest newLinkBehavior', () => { ...@@ -19,12 +19,10 @@ 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': `
...@@ -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: {
......
...@@ -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': '14.0.0', '@testing-library/react': '15.0.2',
'@testing-library/jest-dom': '5.17.0', '@testing-library/jest-dom': '5.17.0',
}, },
}) })
......
...@@ -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 } = renderFn( 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': '13.1.1', '@testing-library/react': '15.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',
......
...@@ -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 } = renderFn( 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: '27.4.7', jest: '29.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: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment