React-native-vector-icons: TypeError: Cannot read property 'OS' of undefined

Created on 11 May 2017  路  5Comments  路  Source: oblador/react-native-vector-icons

v3.0.0

While testing application with Jest throws an error:

TypeError: Cannot read property 'OS' of undefined

      at createIconSet (node_modules/react-native-vector-icons/lib/create-icon-set.js:26:25)
      at Object.<anonymous> (node_modules/react-native-vector-icons/FontAwesome.js:9:28)
...
import FontAwesome from 'react-native-vector-icons/FontAwesome';

Most helpful comment

@iegik Try it

jest.mock('react-native', () => ({
  NativeModules: {
    RNPasscodeStatus: {
      supported: jest.fn(),
      status: jest.fn(),
      get: jest.fn(),
    }
  },
  StyleSheet: {
    create: () => ({})
  },
  Platform: {
    OS: jest.fn(() => 'android'),
    version: jest.fn(() => 25),
  },
}));

All 5 comments

I got the similar issue did any one find solution for the above ?

TypeError: Cannot read property 'osVersion' of undefined

  at Object.get Version [as Version] (node_modules/react-native/Libraries/Utilities/Platform.ios.js:18:45)
  at Object.<anonymous> (src/common/Touchable.js:5:53)
  at Object.<anonymous> (src/common/CustomButton1.js:5:16)
  at Object.<anonymous> (src/pages/LoginScreen.js:4:19)

@iegik Try it

jest.mock('react-native', () => ({
  NativeModules: {
    RNPasscodeStatus: {
      supported: jest.fn(),
      status: jest.fn(),
      get: jest.fn(),
    }
  },
  StyleSheet: {
    create: () => ({})
  },
  Platform: {
    OS: jest.fn(() => 'android'),
    version: jest.fn(() => 25),
  },
}));

@linhnh123 doesn't work for me.

does not works for me also :tophat:
TypeError: Super expression must either be null or a function

Think, that @linhnh123 solution should work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lossen picture lossen  路  4Comments

tharrington picture tharrington  路  4Comments

fevzican picture fevzican  路  3Comments

reactor123 picture reactor123  路  3Comments

arjs1000 picture arjs1000  路  3Comments