You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests 1 and 2 use the <NativeBaseProvider /> as wrapper and both libraries gets the same error.
console.error
The above error occurred in the <ForwardRef> component:
at debug (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/utils/styled.js:18:5)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/components/primitives/Pressable/Pressable.js:72:3)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/components/primitives/Button/Button.js:38:3)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/@react-aria/ssr/dist/SSRProvider.main.js:75:154)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/components/composites/Toast/Toast.js:139:3)
at useState (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/@react-native-aria/overlays/lib/commonjs/Portal.js:17:44)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/core/hybrid-overlay/HybridProvider.js:23:3)
at disableCSSMediaQueries (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/utils/useResponsiveQuery/ResponsiveQueryProvider.js:21:14)
at RNCSafeAreaProvider
at Component (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/react-native/jest/mockNativeComponent.js:17:18)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/react-native-safe-area-context/lib/commonjs/SafeAreaContext.js:35:3)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/utils/createContext.js:17:7)
at colorModeManager (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/core/NativeBaseProvider.js:56:5)
at RNCSafeAreaProvider
at Component (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/react-native/jest/mockNativeComponent.js:17:18)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/react-native-safe-area-context/lib/commonjs/SafeAreaContext.js:35:3)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/__tests__/App.test.tsx:16:19)
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
25 |
26 | it('Render NativeBase Button with @testing-library/react-native', () => {
> 27 | render(
| ^
28 | <Wrapper>
29 | <Button>Test</Button>
30 | </Wrapper>
at logCapturedError (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:8678:23)
at logCapturedError (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:8711:5)
at call (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5175:12)
at callCallback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5196:9)
at commitUpdateQueue (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:13271:13)
at commitLayoutEffectOnFiber (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14369:9)
at commitLayoutMountEffects_complete (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14355:7)
at commitLayoutEffects_begin (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14340:3)
at commitLayoutEffects (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16101:5)
at commitRootImpl (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15972:5)
at commitRoot (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15493:3)
at callback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:2597:22)
at callback (node_modules/react/cjs/react.development.js:2667:24)
at flushActQueue (node_modules/react/cjs/react.development.js:2521:11)
at actImplementation (node_modules/@testing-library/react-native/build/act.js:31:25)
at renderWithAct (node_modules/@testing-library/react-native/build/render-act.js:14:24)
at renderInternal (node_modules/@testing-library/react-native/build/render.js:54:48)
at renderInternal (node_modules/@testing-library/react-native/build/render.js:29:10)
at Object.<anonymous> (__tests__/App.test.tsx:27:11)
console.error
The above error occurred in the <ForwardRef> component:
at debug (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/utils/styled.js:18:5)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/components/primitives/Pressable/Pressable.js:72:3)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/components/primitives/Button/Button.js:38:3)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/@react-aria/ssr/dist/SSRProvider.main.js:75:154)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/components/composites/Toast/Toast.js:139:3)
at useState (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/@react-native-aria/overlays/lib/commonjs/Portal.js:17:44)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/core/hybrid-overlay/HybridProvider.js:23:3)
at disableCSSMediaQueries (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/utils/useResponsiveQuery/ResponsiveQueryProvider.js:21:14)
at RNCSafeAreaProvider
at Component (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/react-native/jest/mockNativeComponent.js:17:18)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/react-native-safe-area-context/lib/commonjs/SafeAreaContext.js:35:3)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/utils/createContext.js:17:7)
at colorModeManager (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/native-base/lib/commonjs/core/NativeBaseProvider.js:56:5)
at RNCSafeAreaProvider
at Component (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/react-native/jest/mockNativeComponent.js:17:18)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/node_modules/react-native-safe-area-context/lib/commonjs/SafeAreaContext.js:35:3)
at children (/Users/aclopesjr/git_repos/ReactNative/NativeBaseSample/__tests__/App.test.tsx:16:19)
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
34 |
35 | it('Render NativeBase Button with react-test-renderer', () => {
> 36 | const component = renderer.create(
| ^
37 | <Wrapper>
38 | <Button>Test</Button>
39 | </Wrapper>
at logCapturedError (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:8678:23)
at logCapturedError (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:8711:5)
at call (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5175:12)
at callCallback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5196:9)
at commitUpdateQueue (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:13271:13)
at commitLayoutEffectOnFiber (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14369:9)
at commitLayoutMountEffects_complete (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14355:7)
at commitLayoutEffects_begin (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14340:3)
at commitLayoutEffects (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16101:5)
at commitRootImpl (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15972:5)
at commitRoot (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15493:3)
at callback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:2597:22)
at flushSyncCallbacks (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:2576:5)
at flushSyncCallbacksOnlyInLegacyMode (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14949:7)
at scheduleUpdateOnFiber (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:17809:5)
at Object.updateContainer [as create] (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:18549:3)
at Object.create (__tests__/App.test.tsx:36:32)
FAIL __tests__/App.test.tsx
Snapshot Testing
✕ Render NativeBase Button with @testing-library/react-native (283 ms)
✕ Render NativeBase Button with react-test-renderer (15 ms)
✓ Render React Native Text with @testing-library/react-native (3 ms)
✓ Render React Native Text with react-test-renderer
● Snapshot Testing › Render NativeBase Button with @testing-library/react-native
TypeError: Cannot read properties of undefined (reading 'width')
25 |
26 | it('Render NativeBase Button with @testing-library/react-native', () => {
> 27 | render(
| ^
28 | <Wrapper>
29 | <Button>Test</Button>
30 | </Wrapper>
at useResponsiveQuery (node_modules/native-base/lib/commonjs/utils/useResponsiveQuery/useResponsiveQuery.js:19:62)
at useStyledSystemPropsResolver (node_modules/native-base/lib/commonjs/hooks/useStyledSystemPropsResolver.js:38:49)
at node_modules/native-base/lib/commonjs/utils/styled.js:21:71
at Component (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5608:18)
at renderWithHooks (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9169:20)
at updateForwardRef (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11400:16)
at beginWork$1 (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15850:12)
at performUnitOfWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15784:5)
at workLoopSync (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15756:7)
at renderRootSync (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15461:20)
at callback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:2597:22)
at callback (node_modules/react/cjs/react.development.js:2667:24)
at flushActQueue (node_modules/react/cjs/react.development.js:2521:11)
at actImplementation (node_modules/@testing-library/react-native/build/act.js:31:25)
at renderWithAct (node_modules/@testing-library/react-native/build/render-act.js:14:24)
at renderInternal (node_modules/@testing-library/react-native/build/render.js:54:48)
at renderInternal (node_modules/@testing-library/react-native/build/render.js:29:10)
at Object.<anonymous> (__tests__/App.test.tsx:27:11)
● Snapshot Testing › Render NativeBase Button with react-test-renderer
TypeError: Cannot read properties of undefined (reading 'width')
34 |
35 | it('Render NativeBase Button with react-test-renderer', () => {
> 36 | const component = renderer.create(
| ^
37 | <Wrapper>
38 | <Button>Test</Button>
39 | </Wrapper>
at useResponsiveQuery (node_modules/native-base/lib/commonjs/utils/useResponsiveQuery/useResponsiveQuery.js:19:62)
at useStyledSystemPropsResolver (node_modules/native-base/lib/commonjs/hooks/useStyledSystemPropsResolver.js:38:49)
at node_modules/native-base/lib/commonjs/utils/styled.js:21:71
at Component (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5608:18)
at renderWithHooks (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9169:20)
at updateForwardRef (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11400:16)
at beginWork$1 (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15850:12)
at performUnitOfWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15784:5)
at workLoopSync (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15756:7)
at renderRootSync (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:15461:20)
at callback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:2597:22)
at flushSyncCallbacks (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:2576:5)
at flushSyncCallbacksOnlyInLegacyMode (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14949:7)
at scheduleUpdateOnFiber (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:17809:5)
at Object.updateContainer [as create] (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:18549:3)
at Object.create (__tests__/App.test.tsx:36:32)
Test Suites: 1 failed, 1 total
Tests: 2 failed, 2 passed, 4 total
Snapshots: 2 passed, 2 total
Time: 2.949 s, estimated 3 s
Ran all test suites related to changed files.
The text was updated successfully, but these errors were encountered:
The jest.config.js file has the property setupFiles. So, for my surprise, when I remove that property, the test passed. And that made me think that the issue would be missing mock piece of code. So, I started to review the mocks and I found out the one was causing the issue.
Description
Testing Snapshot NativeBase components failed
CodeSandbox/Snack link
https://github.com/toninlopes/NativeBaseSample
Steps to reproduce
yarn test
NativeBase Version
3.4.28
Platform
Other Platform
No response
Additional Information
I have set up a standard React Native + Native Base project. See the package.json.
Here is a simple snapshot test with @testing-library/react-native and react-test-renderer.
Tests 1 and 2 use the
<NativeBaseProvider />
as wrapper and both libraries gets the same error.The text was updated successfully, but these errors were encountered: