vanGalilea/react-native-testing

home test is brokwn

hsavit1 opened this issue · 2 comments

first off, thank you for this library. it's current the best example of react native testing on the internet.

unfortunately, not all tests are working. this is the output I got from the home test

 FAIL  __tests__/Home-test.tsx
   Console

    console.error
      Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

       9 | 
      10 | it('renders/navigats throughout app screens', async () => {
    > 11 |   const {getByText} = render(<App />)
         |                              ^
      12 |   const homeText = getByText(/home/i)
      13 |   expect(homeText).not.toBeNull()
      14 |   fireEvent.press(getByText(/counter/i))

      at BufferedConsole.console.error (node_modules/react-native/Libraries/LogBox/LogBox.js:33:14)
      at registerError (node_modules/react-native/Libraries/YellowBox/YellowBox.js:197:7)
      at errorImpl (node_modules/react-native/Libraries/YellowBox/YellowBox.js:84:22)
      at BufferedConsole.console.error (node_modules/react-native/Libraries/YellowBox/YellowBox.js:63:14)
      at printWarning (node_modules/react/cjs/react.development.js:315:30)
      at error (node_modules/react/cjs/react.development.js:287:5)
      at Object.createElementWithValidation [as createElement] (node_modules/react/cjs/react.development.js:1788:7)
      at _callee$ (__tests__/Home-test.tsx:11:30)

    console.error
      The above error occurred in the <View> component:
          in View (created by View)
          in View (created by AppContainer)
          in View (created by View)
          in View (created by AppContainer)
          in AppContainer (at src/index.js:26)
      
      Consider adding an error boundary to your tree to customize error handling behavior.
      Visit https://fb.me/react-error-boundaries to learn more about error boundaries.

      at BufferedConsole.console.error (node_modules/react-native/Libraries/LogBox/LogBox.js:33:14)
      at registerError (node_modules/react-native/Libraries/YellowBox/YellowBox.js:169:7)
      at errorImpl (node_modules/react-native/Libraries/YellowBox/YellowBox.js:84:22)
      at BufferedConsole.console.error (node_modules/react-native/Libraries/YellowBox/YellowBox.js:63:14)
      at logCapturedError (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:10141:21)
      at logError (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:10178:5)
      at update.callback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11288:5)
      at callCallback (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:3259:12)

I was able to fix this by referring to "./App" as "./App.tsx" from within the Home.tsx directory

You can make a PR to share this with everyone ;) a colleague of mine had that problem also @kamaal111 it might be an iOS issue. Are you using iOS? @hsavit1