-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Ensure the right versions of React / adapters are installed #2116
Conversation
…ons of React / adapters are installed
import semver from 'semver'; | ||
|
||
export default function getAdapterForReactVersion(reactVersion) { | ||
const normalizedVersion = semver.coerce(reactVersion); |
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.
Need this because something like "16.3" isn't a valid version, per semver.
Their docs state that coerce
is guaranteed to generate a version as long as there is a number in the string.
@@ -0,0 +1,86 @@ | |||
import { expect } from 'chai'; | |||
import getAdapterForReactVersion from '../../enzyme-adapter-react-helper/src/getAdapterForReactVersion'; |
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.
Feel like I should've been able to do
import getAdapterForReactVersion from 'enzyme-adapter-react-helper/src/getAdapterForReactVersion';
Didn't work, though 🤔
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.
i think if you add enzyme-adapter-react-helper
as a dev dep of enzyme-test-suite
, that this will work?
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.
Oh, that would make sense
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.
Thanks, this looks great.
return 'enzyme-adapter-react-13'; | ||
} | ||
|
||
return 'enzyme-adapter-react-16'; |
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.
we didn't used to have this fallback here - should it throw instead?
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.
Yeah, that's probably better than randomly getting the -16 adapter
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.
Thanks!
- [fix] `install`: Ensure the right versions of React / adapters are installed (#2116) - [dev deps] update `eslint`, `semver`, `rimraf`, `eslint-plugin-react`, `eslint-plugin-import` - [build] include source maps
There's a weird issue where partial React versions can result in the wrong versions of React being installed. This happens because
semver.intersects
is returning something weird when both are true:See this truth table which highlights the issue.
In this PR we:
semver.satisfies
fromsemver.intersects
@ljharb , what do you think?