2017-09-01 57 views
0

我有Redux的一個代碼,我導出爲JEST測試沒有按預期工作

export default connect(mapStateToLinkProps, mapDispatchToLinkProps)(Link); 

而且在開玩笑測試情況下,我已經寫測試這個出口組件

//imported the above component as Link 
describe('Dashboard component testing',() => { 
    test('1. Must be an Instance of CreateAssest',() => { 
    const wrapper = shallow(<FilterLink />); 
    const inst = wrapper.instance(); 
    expect(inst).toBeInstanceOf(Link); 
    }); 
}); 

對於這是我得到錯誤

不可違反:找不到「存儲」的上下文或 道具的「連接(鏈接)」。將根組件包裝在 中,或者將「store」作爲道具顯式傳遞給「Connect(鏈接)」。

當不使用終極版,僅出口爲反應元件進行檢查的病例working.Now在終極版的一些商店的問題是coming.please任何人都可以引導一個小在這個問題上發生了什麼

回答

1

你需要用您的組件在Provider中以便能夠使用存儲,如下所示:

import { Provider, connect } from "react-redux"; 
let store = createStore(reducer, defaultStoreItems); 
<Provider store={store}> 
    <App />  
</Provider>