Use @testing-library
instead of react-dom/test-utils (#65328)
Closes NEXT-3313
This commit is contained in:
parent
44a21f4cc2
commit
79afd61da5
1 changed files with 3 additions and 33 deletions
|
@ -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')
|
||||
})
|
||||
|
@ -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')
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue