-
-
Notifications
You must be signed in to change notification settings - Fork 44
Cannot convert undefined or null to object at assign (<anonymous>) #126
Comments
- Currently facing issue testing-library/native-testing-library#126.
This holds us back on upgrading our project. |
This is holding us back upgrading too |
+1 |
I haven't investigated what would fix it, but based on the stacktrace, I think the react-native commit that caused the breakage is facebook/react-native@6e3389c, which is an import of facebook/react@2d6be75 from react. That commit removed the NativeMethodsMixin export referenced at https://github.com/testing-library/native-testing-library/blob/master/src/preset/mock-modules.js#L38. |
I explored RN library code in // Re-mock ReactNative with native methods mocked
jest
.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper')
.doMock('react-native/Libraries/Renderer/shims/ReactNative', () => {
const ReactNative = jest.requireActual('react-native/Libraries/Renderer/shims/ReactNative');
const NativeMethodsMixin =
ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.NativeMethodsMixin;
Object.assign(NativeMethodsMixin, mockNativeMethods);
Object.assign(ReactNative.NativeComponent.prototype, mockNativeMethods);
return ReactNative;
}); The fields of This seems to the adaption processing of the new React fiber. |
@TheSavior, any ideas what can be used instead here? Looks like it was this PR that removed this functionality facebook/react#18036 |
Based on @mym0404's comment, that mock for ReactNative is trying to override
|
@TheSavior The native methods of component like
|
I'd recommend looking at how those components with native methods, like ScrollView, is mocked in core: https://github.com/facebook/react-native/blob/master/jest/setup.js#L133-L152 |
It works like a charm. Thank you :). my project is upgraded to 0.63 successfully. |
I've fixed this in #136 🎉 |
Awaiting new release to update our project 👍 |
You can now upgrade to version |
react-native
orexpo
: RNnative-testing-library
version:5.0.3
jest-preset
:^26.0.1
react-native
version:0.63.0-rc.1
node
version:v12.0.0
Relevant code or config:
Repo with steps to reproduce
What you did:
Upon upgrading from React Native 0.62.2 to React Native 0.63.0-rc.1 (to pre-empt the upcoming release,) all of my tests broke.
What happened:
The stack trace differs based on the component, but it is always
Cannot convert undefined or null to object
Reproduction:
Clone this repo and run the tests.
If you change the
jest.config.js
tothe issue error is resolved
Problem description:
Tests fail. 🤷♂️
Suggested solution:
Can't dig into it too much atm
Can you help us fix this issue by submitting a pull request?
I'd love to, but other priorities with work.
The text was updated successfully, but these errors were encountered: