Skip to content

Commit

Permalink
Use @testing-library instead of react-dom/test-utils (vercel#65328)
Browse files Browse the repository at this point in the history
Closes NEXT-3313
  • Loading branch information
eps1lon authored May 6, 2024
1 parent 44a21f4 commit 79afd61
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions test/integration/link-without-router/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,16 @@
* @jest-environment jsdom
*/
import React from 'react'
// eslint-disable-next-line react/no-deprecated
import { render, unmountComponentAtNode } from 'react-dom'
import { act } from 'react-dom/test-utils'
import { render } from '@testing-library/react'

import Hello from '../components/hello'

describe('Link without a router', () => {
let container = null

beforeEach(() => {
container = document.createElement('div')
document.body.appendChild(container)
})

afterEach(() => {
unmountComponentAtNode(container)
container.remove()
container = null
})
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
it('should not throw when rendered', () => {
jest.useFakeTimers()

act(() => {
render(<Hello />, container)
})

act(() => {
jest.runAllTimers()
})
const { container } = render(<Hello />)

expect(container.textContent).toBe('Click me')
})
Expand All @@ -44,15 +22,7 @@ describe('Link without a router', () => {
() => {
// eslint-disable-next-line jest/no-identical-title
it('should not throw when rendered', () => {
jest.useFakeTimers()

act(() => {
render(<Hello />, container)
})

act(() => {
jest.runAllTimers()
})
const { container } = render(<Hello />)

expect(container.textContent).toBe('Click me')
})
Expand Down

0 comments on commit 79afd61

Please sign in to comment.