testing-library/react-hooks-testing-library

Cannot read properties of undefined (reading 'STANDARD_EVENT_ADD_TO_CART')

gHashTag opened this issue · 1 comments

When trying to test the hook in a React Native mobile app, this error:

TypeError: Cannot read properties of undefined (reading 'STANDARD_EVENT_ADD_TO_CART')
at Object.STANDARD_EVENT_ADD_TO_CART (node_modules/react-native-branch/src/BranchEvent.js:208:34)
at Object. (node_modules/react-native-branch/src/branchUniversalObject.js:2:1)

Dependencies:

  • "react": "17.0.2",
  • "react-native": "0.68.2",

DevDepends:

  • "jest": "28.0.3",

  • "jest-fetch-mock": "^3.0.3",

  • "jest-junit": "13.2.0",

  • "@testing-library/jest-native": "4.0.4",

  • "@testing-library/react-hooks": "8.0.0",

  • "@testing-library/react-native": "9.1.0",

  • "react-test-renderer": "17.0.2",

  • node version: 16.15.1

  • npm version: 8.11.0

  • yarn version: 1.22.18

Relevant code or config:

import { renderHook } from '@testing-library/react-hooks' 

function useTest() {
  return { res: true }
}

describe('useTest', () => {
  it('should render', () => {
    const { result } = renderHook(() => useTest())
  })
})

Снимок экрана 2022-06-10 в 17 08 48

That error has absolutely nothing to do with this library. renderHook is nowhere in that stack trace.

If this test is indeed what produces that output then I’d say something is going wrong in a setup file somewhere.