Cnilton / react-native-floating-label-input

A customizable React Native TextInput with its placeholder always shown. Includes masks, global styles, character count, and a bunch else.
MIT License
293 stars 60 forks source link

Unable pass the unit test with some weird errors #91

Closed ngmikeng closed 2 years ago

ngmikeng commented 3 years ago

I try test a component which is using the floating label input but it can't pass the unit test, but another components which are not using the floating label input passed the test.

It throws an error and some weird logs, have anyone seen this before?

Invariant Violation: Unable to locate attached view in the native tree
    at invariant (...)
●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "The above error occurred in the <AnimatedComponent(Text)> component:
        in AnimatedComponent(Text) (created by ForwardRef(AnimatedComponentWrapper))
        in ForwardRef(AnimatedComponentWrapper) (created by ForwardRef(FloatingLabelInput))
        in View (created by View)
        in View (created by ForwardRef(FloatingLabelInput))
        in View (created by View)
        in View (created by ForwardRef(FloatingLabelInput))
        in View (created by View)
        in View (created by ForwardRef(FloatingLabelInput))
        in TouchableWithoutFeedback (created by ForwardRef(FloatingLabelInput))
        in ForwardRef(FloatingLabelInput) (created by Input)
        in View (created by View)
        in View (created by Input)
        in Input
        .....

Thanks for your contribution.

robsmithw commented 2 years ago

@ngmikeng I'm sure you've figured this out by now but incase you haven't.

I seen the same thing and realized it came from react-native-reanimated not being mocked in the test. You can add the following to your setup-test or specific test file. jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock')); I still ended up with more errors from this library around fontsize, but I am still looking into that.

vinniimiranda commented 2 years ago

I am getting this error for the same issue above: Warning: Failed prop type: Invalid prop fontSize of type object supplied to Text, expected number. Bad object: { "paddingVertical": 10, "fontSize": { " __value": 12 }, "fontFamily": "Poppins_400Regular", "left": 5, "alignSelf": "center", "position": "absolute", "flex": 1, "zIndex": 999, "transform": [ { "translateX": { " value": 0 } }, { "translateY": { " value": 0 } } ] }

Cnilton commented 2 years ago

Hi guys, this issue should be fixed in the next version.

Cnilton commented 2 years ago

New version released should fix this!

Cnilton commented 2 years ago

@robsmithw, @vinniimiranda and @ngmikeng, can you please try the latest version?