4a7ab34baf
This updates our `yarn next` command to leverage react v18 by default and removes the need for the test require hook/config modifying when testing react 18. There are some fixtures we need to investigate react 18 support in follow-ups: - `test/integration/client-navigation-a11y` - `test/integration/critical-css` - `test/integration/custom-error-page-exception` - `test/integration/font-optimization` - AMP specific tests
39 lines
784 B
TypeScript
39 lines
784 B
TypeScript
/**
|
|
* @jest-environment jsdom
|
|
*/
|
|
import { act, render } from '@testing-library/react'
|
|
import Link from 'next/link'
|
|
import React from 'react'
|
|
|
|
describe('<Link/>', () => {
|
|
let spy
|
|
let expectedErrors
|
|
beforeAll(async () => {
|
|
spy = jest.spyOn(console, 'error').mockImplementation((...args) => {
|
|
console.log(...args)
|
|
})
|
|
|
|
expectedErrors = 0
|
|
})
|
|
|
|
it('test link with unmount', () => {
|
|
act(() => {
|
|
const { unmount } = render(<Link href="/">hello</Link>)
|
|
unmount()
|
|
})
|
|
|
|
expect(spy).toHaveBeenCalledTimes(expectedErrors)
|
|
})
|
|
|
|
it('test link without unmount', () => {
|
|
act(() => {
|
|
render(<Link href="/">hello</Link>)
|
|
})
|
|
|
|
expect(spy).toHaveBeenCalledTimes(expectedErrors)
|
|
})
|
|
|
|
afterAll(() => {
|
|
spy.mockRestore()
|
|
})
|
|
})
|