Skip to content
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

How to add mock for TabBarIOS.Item? #2131

Closed
osadchuk opened this issue Nov 18, 2016 · 3 comments
Closed

How to add mock for TabBarIOS.Item? #2131

osadchuk opened this issue Nov 18, 2016 · 3 comments

Comments

@osadchuk
Copy link

TabBarIOS is not mocked:

TypeError: Cannot read property '_tag' of null

  at ReactNativeBaseComponent.Mixin.mountComponent (node_modules/react/lib/ReactNativeBaseComponent.js:181:45)
  at Object.ReactReconciler.mountComponent (node_modules/react/lib/ReactReconciler.js:47:35)
  at ReactCompositeComponentMixin.performInitialMount (node_modules/react/lib/ReactCompositeComponent.js:370:34)
  at ReactCompositeComponentMixin.mountComponent (node_modules/react/lib/ReactCompositeComponent.js:257:21)
  at Object.ReactReconciler.mountComponent (node_modules/react/lib/ReactReconciler.js:47:35)
  at ReactCompositeComponentMixin.performInitialMount (node_modules/react/lib/ReactCompositeComponent.js:370:34)
  at ReactCompositeComponentMixin.mountComponent (node_modules/react/lib/ReactCompositeComponent.js:257:21)
at Object.ReactReconciler.mountComponent (node_modules/react/lib/ReactReconciler.js:47:35)
  at ReactCompositeComponentMixin.performInitialMount (node_modules/react/lib/ReactCompositeComponent.js:370:34)
  at ReactCompositeComponentMixin.mountComponent (node_modules/react/lib/ReactCompositeComponent.js:257:21)

Adding a mock for TabBarIOS (in the same way as the mock for Modal was added: #1739) resolves this error. However, TabBarIOS.Item returns the same error, and trying to mock TabBarIOS.Item the same way:

mock('TabBarIOS.Item', () => mockReactNative.mockComponent('TabBarIOS.Item')).

results in the following error:

Cannot find module 'TabBarIOS.Item' from 'setup.js'

  at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:151:17)

Is there a way to mock tab bar items? I'd be happy to submit a PR with the mocks for both, just need a little help with the syntax (I'm pretty new to Jest).

Thanks!

@browniefed
Copy link
Contributor

@osadchuk
Copy link
Author

Thanks - managed to get that working, so I'll close this issue.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants