The problem
After update from RNW 0.6.1 to 0.8.8 all unit tests broken with error:
TypeError: Cannot read property 'createAnimatedComponent' of undefined
How to reproduce
Steps to reproduce:
Expected behavior
Tests passed
Environment (include versions). Did this work in previous versions?
Additional context
Error report
All tests has same error.
Test suite failed to run
TypeError: Cannot read property 'createAnimatedComponent' of undefined
42 | export { durableAxios, axiosWithIdleTimeout };
43 |
> 44 | export function copyToClipboard(text: string) {
45 | clipboard.writeText(text);
46 | }
47 |
at Object.<anonymous> (node_modules/react-native-web/dist/cjs/exports/Animated/index.js:28:40)
at Object.<anonymous> (node_modules/react-native-web/dist/cjs/index.js:50:15)
at Object.<anonymous> (src/core/adapter.web.js:44:799)
at Object.<anonymous> (src/utils/offline.js:3:81)
at Object.<anonymous> (src/utils/cache.js:4:98)
at Object.<anonymous> (test-setup.js:2:87)
p.s. May be it's not a bug with RNW, but I didn't find any information on the web, sorry.
Did you read through the release notes and look at the breaking changes? https://github.com/necolas/react-native-web/releases
@necolas sorry, can you clarify which point is related to this? (I read 0.8 and 0.7 breaking changes notes)
Make sure all the React packages are on the same version, and you have updated or removed the RNW babel plugin. There's no problem with the codesandbox or demos, so the issue is likely to be in your project configuration.
My problem was inside moduleNameMapper option inside Jest config in package.json
Not worked: "react-native": "<rootDir>/node_modules/react-native-web",
Worked: "^react-native$": "react-native-web",
Most helpful comment
My problem was inside moduleNameMapper option inside Jest config in package.json
Not worked:
"react-native": "<rootDir>/node_modules/react-native-web",Worked:
"^react-native$": "react-native-web",