After updating to the latest version of enzyme-adapter-react-16 (which itself then uses the latest version of enzyme-adapter-utils, all tests fail with the following error:
FAIL lib/selectors/__tests__/consent.spec.js
â—Ź Test suite failed to run
TypeError: (0 , _semver.intersects) is not a function
at Object.<anonymous> (node_modules/enzyme-adapter-utils/build/wrapWithSimpleWrapper.js:45:39)
at Object.<anonymous> (node_modules/enzyme-adapter-utils/build/Utils.js:52:30)
If I rollback enzyme-adapter-react-16 to 1.6.0 and pin enzyme-adapter-utils to 1.8.0, it will no longer crash. The version of enzyme itself does not seem to have an effect on this error.
This was part of an effort to update all our libraries, including semver, though rolling that back did not seem to help. We also did a major update of React and Reach Native (which I know is technically not supported, but I don't _think_ is the cause of this specific error.
Tests shouldn't crash on dependencies of dependencies.
| library | version
| ------------------- | -------
| enzyme | 3.10.0
| react | 16.8.3
| react-dom | 16.8.3
| react-test-renderer | 16.8.3
| adapter (below) | 1.14.0
This is almost certainly unrelated to enzyme, except that your node_modules layout probably changed while upgrading multiple deps at once.
Can you revert back to a lockfile from before you upgraded multiple deps at once, and try upgrading only one at a time? Also, can you confirm you’re using npm, or if not, which cli you are using?
Yes, I am using npm.
I have rolled back enzyme-adapter-react-16 to 1.6.0 and enzyme-adapter-utils to 1.8.0, which circumvents this error but I then don't get needed changes in those libraries for other errors I face. I have cloned everything into a new directly and installed all the npm dependencies from scratch, so it's definitely not a direct upgrade issue, though it is certainly possible a conflict with another library. It is though, I am at a loss for what it is conflicting with.
Do you have a lockfile?
Yes, you can see it here: https://drive.google.com/file/d/126Hgl-O5GBMMwuaAukrWa4p9bNaO7Cuk/view?usp=sharing
i had the same issue.
it seems enzyme-adapter-react-16 uses "semver": "^5.7.0"
what i did was to install "semver" as a dev dependency and the error dissapeard.
_npm install semver --save-dev_
Deleting package-lock.json and re-installing the npm packages solves the issue. There is no need to add semver as a dependency. semver will be added by enzyme-adapter-react-16
@joelshea considering that it looks like a lockfile issue, is this something you've been able to resolve?
No, deleting the package-lock.json and reinstalling definitely did not fix it. That just puts me in the same situation I started in. I don't think this is a lockfile issue, if anything I think it is maybe a dependency conflict issue? There are many libraries using semver and they use all sorts of different versions.
What’s especially odd is that the intersects method has been available for many versions of semver. Is there any chance your jest config is mocking it somehow?
YES! That was it! Oh man, how embarrassing. semver was being mocked, but since I am new to javascript and that error was so vague, I didn't realize it was trying to tell me that more functions needed to be mocked.
Sorry for the run around, but thanks for your help!
Most helpful comment
Deleting package-lock.json and re-installing the npm packages solves the issue. There is no need to add semver as a dependency. semver will be added by enzyme-adapter-react-16