entria / ReactNavigationRelayModern

React Navigation integration with Relay
173 stars 23 forks source link

feat(relay): add tests using react-native-testing-library #32

Closed sibelius closed 5 years ago

sibelius commented 5 years ago

we are getting this error

 Failed: "TypeError: Cannot read property 'default' of undefined"

      at Env.fail (node_modules/jest-jasmine2/build/jasmine/Env.js:540:34)
      at node_modules/relay-runtime/lib/RelayObservable.js:638:7
      at Object.next (node_modules/relay-runtime/lib/RelayObservable.js:562:11)
      at Object.next (node_modules/relay-runtime/lib/RelayObservable.js:560:20)
      at Object.next (node_modules/relay-runtime/lib/RelayObservable.js:226:40)
      at Object.next (node_modules/relay-runtime/lib/RelayObservable.js:560:20)
      at Object.next (node_modules/relay-runtime/lib/RelayObservable.js:560:20)
      at node_modules/relay-runtime/lib/RelayObservable.js:491:10
      at _subscribe (node_modules/relay-runtime/lib/RelayObservable.js:608:15)
TypeError: Cannot read property 'default' of undefined
        at new UserList (ReactNavigationRelayModern/src/UserList.js:29:407)
        at constructClassInstance (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:4103:22)
        at updateClassComponent (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5825:11)
        at beginWork (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6424:20)
        at performUnitOfWork (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:8752:16)
        at workLoop (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:8783:28)
        at renderRoot (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:8862:11)
        at performWorkOnRoot (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9693:11)
        at performWork (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9601:11)
        at performSyncWork (ReactNavigationRelayModern/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9573:7)
thymikee commented 5 years ago

cross-posting this: https://github.com/callstack/react-native-testing-library/issues/27#issuecomment-432401138

sibelius commented 5 years ago

for some reason, when rendering

createFragmentContainer createPaginationContainer createRefetchContainer

it causes a bug

thymikee commented 5 years ago

Can you isolate it to minimal example repo and share it with me? I'd take a closer look and file a bug report in React if necessary

thymikee commented 5 years ago

I'm on a mobile now so can't verify easily, but your transformIgnorePatterns seems not very permissive and it's possible that the lib code is not being transpiled. Can you remove this last slash in the pattern? It should then transform any react-native-* lib as well

sibelius commented 5 years ago

this is the error when using error boundary

 title="TypeError: Cannot read property 'default' of undefined

    This is located at:
        in UserList (created by ContainerConstructor)
        in ContainerConstructor (created by ForwardRef(Relay(UserList)))
        in ErrorBoundary (at UserList.spec.js:65)
        in RelayContextProvider (at UserList.spec.js:61)"

I think this is a minimal example

removing transformIgnorePatterns does not change anything

thymikee commented 5 years ago

Oh, and ErrorBoundary renders null by default, so that would make sense.

sibelius commented 5 years ago

I've merged this but it still not working