RealOrangeOne / react-native-mock

A fully mocked and test-friendly version of react native (maintainers wanted)
MIT License
571 stars 153 forks source link

Enzyme's mount() failed when trying to render Animated.View #78

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi, I'm trying to test component which has Animated.View, but when I call the enzyme's mount() I'm getting an error TypeError: Cannot read property '__getValue' of undefined

the full stack is: TypeError: Cannot read property '__getValue' of undefined at AnimatedComponent.render (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react-native-mock\build\api\Animated\createAnimatedComponent.js:10:20) at [object Object].ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:687:34) at [object Object].ReactCompositeComponentMixin._renderValidatedComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:707:32) at [object Object].wrapper as _renderValidatedComponent at [object Object].ReactCompositeComponentMixin.performInitialMount (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:291:30) at [object Object].ReactCompositeComponentMixin.mountComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:222:21) at [object Object].wrapper as mountComponent at Object.ReactReconciler.mountComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactReconciler.js:39:35) at [object Object].ReactCompositeComponentMixin.performInitialMount (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:297:34) at [object Object].ReactCompositeComponentMixin.mountComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:222:21) at [object Object].wrapper as mountComponent at Object.ReactReconciler.mountComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactReconciler.js:39:35) at [object Object].ReactCompositeComponentMixin.performInitialMount (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:297:34) at [object Object].ReactCompositeComponentMixin.mountComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:222:21) at [object Object].wrapper as mountComponent at Object.ReactReconciler.mountComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactReconciler.js:39:35) at [object Object].ReactCompositeComponentMixin.performInitialMount (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:297:34) at [object Object].ReactCompositeComponentMixin.mountComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactCompositeComponent.js:222:21) at [object Object].wrapper as mountComponent at Object.ReactReconciler.mountComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactReconciler.js:39:35) at mountComponentIntoNode (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactMount.js:103:32) at ReactReconcileTransaction.Mixin.perform (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\Transaction.js:136:20) at batchedMountComponentIntoNode (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactMount.js:124:15) at ReactDefaultBatchingStrategyTransaction.Mixin.perform (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\Transaction.js:136:20) at Object.ReactDefaultBatchingStrategy.batchedUpdates (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactDefaultBatchingStrategy.js:63:19) at Object.batchedUpdates (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactUpdates.js:97:20) at Object.ReactMount._renderNewRootComponent (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactMount.js:277:18) at Object.wrapper as _renderNewRootComponent at Object.ReactMount._renderSubtreeIntoContainer (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactMount.js:354:32) at Object.ReactMount.render (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactMount.js:374:23) at Object.wrapper as render at Object.ReactTestUtils.renderIntoDocument (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\react\lib\ReactTestUtils.js:78:21) at renderWithOptions (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\enzyme\build\react-compat.js:175:26) at new ReactWrapper (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\enzyme\build\ReactWrapper.js:94:59) at mount (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\enzyme\build\mount.js:21:10) at Context. (ContactSupportInputContainerSpec.js:213:25) at callFn (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\mocha\lib\runnable.js:326:21) at Test.Runnable.run (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\mocha\lib\runnable.js:319:7) at Runner.runTest (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\mocha\lib\runner.js:422:10) at C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\mocha\lib\runner.js:528:12 at next (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\mocha\lib\runner.js:342:14) at C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\mocha\lib\runner.js:352:7 at next (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\mocha\lib\runner.js:284:14) at Immediate._onImmediate (C:\Git{xxx}{aaa}\reactNativeSrc\node_modules\mocha\lib\runner.js:320:5)

please advice, Noam

RealOrangeOne commented 8 years ago

Looking at the source, it appears it's a bug that's carried through from day 1. Seems it's trying to access a special prop that isnt there. Although, i'm not sure what it's meant to be, or how it really works

ywongweb commented 8 years ago

Bump into the same problem here. shallow() works but mount() throws the error.

RealOrangeOne commented 8 years ago

I believe that's something to do with how shallow doesnt render everything. Mount is definitely a better test of this library, although it is only designed to be used with shallow. There's still an error in the codebase though

faceyspacey commented 7 years ago

+1

alixeb commented 7 years ago

having the same issue