/** * @jest-environment jsdom */ import { act, render } from '@testing-library/react' import Link from 'next/link' import React from 'react' describe('', () => { 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(hello) unmount() }) expect(spy).toHaveBeenCalledTimes(expectedErrors) }) it('test link without unmount', () => { act(() => { render(hello) }) expect(spy).toHaveBeenCalledTimes(expectedErrors) }) afterAll(() => { spy.mockRestore() }) })