i upgraded redux-form 5.3.2 6.0.1, unit test works in 5.3.2 failed in 6.0.1.
/* myform.jsx */ ... import { field, reduxform } 'redux-form'; class myform extends component { ... <form onsubmit={handlesubmit(...)}> ... } export default reduxform({ form: 'myform' })(myform);
i mounted form reducer before render form:
import {reducer formreducer} 'redux-form'; const myreducer = combinereducers({ ... form: formreducer });
here store, created in top level component:
const createstorewithmiddleware = applymiddleware(thunkmiddleware)(createstore); const store = createstorewithmiddleware(myreducer);
my test case (karma + jasmine), works in 5.3.2, failed in 6.0.1
/* form.test.js */ import react, { proptypes } 'react'; import testutils 'react/lib/reacttestutils'; import finddomnode 'react/lib/finddomnode'; import { provider } 'react-redux'; ... import myform '../myform'; const createstorewithmiddleware = applymiddleware(thunkmiddleware)(createstore); const store = createstorewithmiddleware(myreducer); describe('myform', () => { beforeall(function() { this.props = { ... store: store } }); it('should render', function() { const element = testutils.renderintodocument( <myform {...this.props} /> ); expect(element).tobetruthy(); });
error: invariant violation: not find "store" in either context or props of "connect(connectedfield)". either wrap root component in <provider>, or explicitly pass "store" prop "connect(connectedfield)".
if use provider pass in store, error:
it('should render', function() { const element = testutils.renderintodocument( <provider store={ store }> { () => <myform {...this.props} />} </provider> ); expect(element).tobetruthy(); });
*
error: invariant violation: onlychild must passed children 1 child. error: 'warning: failed proptype: invalid prop `children` supplied `provider`, expected single reactelement.'
*
any ideas why test failed? searched online not find information specific topic.
thanks,
Comments
Post a Comment