Unverified Commit 1f09a78e authored by Gerald Monaco's avatar Gerald Monaco Committed by GitHub

Fix react@next and react@experimental tests (#26088)

parent 1ebf26af
...@@ -31,6 +31,7 @@ jobs: ...@@ -31,6 +31,7 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
HEADLESS: true HEADLESS: true
NEXT_PRIVATE_SKIP_SIZE_TESTS: true NEXT_PRIVATE_SKIP_SIZE_TESTS: true
NEXT_PRIVATE_REACT_ROOT: 1
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
......
...@@ -3,11 +3,21 @@ ...@@ -3,11 +3,21 @@
*/ */
import { act, render } from '@testing-library/react' import { act, render } from '@testing-library/react'
import Link from 'next/link' 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('<Link/>', () => { describe('<Link/>', () => {
let spy let spy
beforeAll(() => { let expectedErrors
beforeAll(async () => {
spy = jest.spyOn(console, 'error').mockImplementation(() => {}) 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', () => { it('test link with unmount', () => {
...@@ -16,7 +26,7 @@ describe('<Link/>', () => { ...@@ -16,7 +26,7 @@ describe('<Link/>', () => {
unmount() unmount()
}) })
expect(spy).not.toHaveBeenCalled() expect(spy).toHaveBeenCalledTimes(expectedErrors)
}) })
it('test link without unmount', () => { it('test link without unmount', () => {
...@@ -24,7 +34,7 @@ describe('<Link/>', () => { ...@@ -24,7 +34,7 @@ describe('<Link/>', () => {
render(<Link href="/">hello</Link>) render(<Link href="/">hello</Link>)
}) })
expect(spy).not.toHaveBeenCalled() expect(spy).toHaveBeenCalledTimes(expectedErrors)
}) })
afterAll(() => { afterAll(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment