-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Fix tests #1288
chore: Fix tests #1288
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const {jest: jestConfig} = require('kcd-scripts/config') | ||
|
||
module.exports = Object.assign(jestConfig, { | ||
coverageThreshold: { | ||
...jestConfig.coverageThreshold, | ||
// Full coverage across the build matrix (React versions) but not in a single job | ||
// Ful coverage is checked via codecov | ||
'./src/pure.js': { | ||
// minimum coverage of jobs using different React versions | ||
branches: 97, | ||
functions: 88, | ||
lines: 94, | ||
statements: 94, | ||
}, | ||
}, | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,13 @@ import ReactDOM from 'react-dom' | |
import ReactDOMServer from 'react-dom/server' | ||
import {fireEvent, render, screen, configure} from '../' | ||
|
||
// Needs to be changed to 19.0.0 once alpha started. | ||
const isReactExperimental = React.version.startsWith('18.3.0-experimental') | ||
const isReactCanary = React.version.startsWith('18.3.0') | ||
|
||
// Needs to be changed to isReactExperimental || isReactCanary once alpha started. | ||
const testGateReact18 = isReactExperimental ? test.skip : test | ||
|
||
describe('render API', () => { | ||
let originalConfig | ||
beforeEach(() => { | ||
|
@@ -213,27 +220,35 @@ describe('render API', () => { | |
expect(wrapperComponentMountEffect).toHaveBeenCalledTimes(1) | ||
}) | ||
|
||
test('legacyRoot uses legacy ReactDOM.render', () => { | ||
testGateReact18('legacyRoot uses legacy ReactDOM.render', () => { | ||
expect(() => { | ||
render(<div />, {legacyRoot: true}) | ||
}).toErrorDev( | ||
[ | ||
"Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot", | ||
], | ||
isReactCanary | ||
? [ | ||
"Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://react.dev/link/switch-to-createroot", | ||
] | ||
: [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this? the reactjs.org link has a redirect to the react.dev one. Is this some sort of preparation for future stuff? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what React is logging |
||
"Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot", | ||
], | ||
{withoutStack: true}, | ||
) | ||
}) | ||
|
||
test('legacyRoot uses legacy ReactDOM.hydrate', () => { | ||
testGateReact18('legacyRoot uses legacy ReactDOM.hydrate', () => { | ||
const ui = <div /> | ||
const container = document.createElement('div') | ||
container.innerHTML = ReactDOMServer.renderToString(ui) | ||
expect(() => { | ||
render(ui, {container, hydrate: true, legacyRoot: true}) | ||
}).toErrorDev( | ||
[ | ||
"Warning: ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot", | ||
], | ||
isReactCanary | ||
? [ | ||
"Warning: ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://react.dev/link/switch-to-createroot", | ||
] | ||
: [ | ||
"Warning: ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot", | ||
], | ||
{withoutStack: true}, | ||
) | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ SOFTWARE. | |
/* eslint-disable func-names */ | ||
/* eslint-disable complexity */ | ||
const util = require('util') | ||
const jestDiff = require('jest-diff').default | ||
const jestDiff = require('jest-diff').diff | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea why this ever worked. It didn't change in |
||
const shouldIgnoreConsoleError = require('./shouldIgnoreConsoleError') | ||
|
||
function normalizeCodeLocInfo(str) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check for
React.version.startsWith('18.3.0-canary')
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep