diff --git a/.github/workflows/test_react_next.yml b/.github/workflows/test_react_next.yml index 0c4c7db08632b..4845ca86c9a5a 100644 --- a/.github/workflows/test_react_next.yml +++ b/.github/workflows/test_react_next.yml @@ -31,6 +31,7 @@ jobs: NEXT_TELEMETRY_DISABLED: 1 HEADLESS: true NEXT_PRIVATE_SKIP_SIZE_TESTS: true + NEXT_PRIVATE_REACT_ROOT: 1 strategy: fail-fast: false matrix: diff --git a/test/unit/link-warnings.test.js b/test/unit/link-warnings.test.js index 0db43b5ff6b3a..cbcbc7fbccd68 100644 --- a/test/unit/link-warnings.test.js +++ b/test/unit/link-warnings.test.js @@ -3,11 +3,21 @@ */ import { act, render } from '@testing-library/react' import Link from 'next/link' +import React from 'react' +import { getPackageVersion } from 'next/dist/lib/get-package-version' +import semver from 'next/dist/compiled/semver' describe('', () => { let spy - beforeAll(() => { + let expectedErrors + beforeAll(async () => { spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + + const reactVersion = await getPackageVersion({ + cwd: __dirname, + name: 'react-dom', + }) + expectedErrors = reactVersion && semver.gte(reactVersion, '18.0.0') ? 1 : 0 }) it('test link with unmount', () => { @@ -16,7 +26,7 @@ describe('', () => { unmount() }) - expect(spy).not.toHaveBeenCalled() + expect(spy).toHaveBeenCalledTimes(expectedErrors) }) it('test link without unmount', () => { @@ -24,7 +34,7 @@ describe('', () => { render(hello) }) - expect(spy).not.toHaveBeenCalled() + expect(spy).toHaveBeenCalledTimes(expectedErrors) }) afterAll(() => {