cooperka / react-native-snackbar

:candy: Material Design "Snackbar" component for Android and iOS.
Other
815 stars 150 forks source link

[Test] Cannot read property 'LENGTH_LONG' of undefined #194

Open vijaemanlapaz opened 2 years ago

vijaemanlapaz commented 2 years ago

I'm getting error _Cannot read property 'LENGTHLONG' of undefined when i do yarn test i'm using version 2.4.0

Environment react-native: 0.65.2 => 0.65.2

Steps i did so far

viral-synoverge commented 2 years ago

how to resolve this ? any one able to find the solution ?

joseananio commented 2 years ago

see this issue: https://github.com/cooperka/react-native-snackbar/issues/43. its on regular usage but you might find something

Also ensure your pods are installed (RNSnackbar (2.4.0)).

atul898 commented 2 years ago

I am getting a similar message - "Cannot read properties of undefined (reading 'LENGTH_LONG')" Functionality is all good, this issue is specific to when running tests We are on React Native "0.67.2", using "2.4.0" of react-native-snackbar Already went through issue #43 and tried everything.

GewoonJaap commented 2 years ago

I am getting a similar message - "Cannot read properties of undefined (reading 'LENGTH_LONG')" Functionality is all good, this issue is specific to when running tests We are on React Native "0.67.2", using "2.4.0" of react-native-snackbar Already went through issue #43 and tried everything.

Same issue here, works fine when using the app, however once I run Jest it will fail. Already added the package to Jest transformIgnorePatterns, without result

ZeeshanAhmadKhalil commented 1 year ago

I was getting this issue, uninstalling app, closing metro server and running app again worked for me.

aravi365 commented 7 months ago

Any working solution or fixes on this issue?

jakequade commented 1 month ago

If anyone is struggling with this, you can create a mock in your jest.setup.js:

jest.mock('react-native-clipboard', () => ({
    LENGTH_SHORT: 5,
    LENGTH_LONG: 10,
    LENGTH_INDEFINITIE: -1,
    show: jest.fn(),
    dismiss: jest.fn(),
})

I've addressed this in a PR, here: https://github.com/cooperka/react-native-snackbar/pull/210