我如何开玩笑地模拟重新选择功能?

How i can mock Reselect functions with jest?

我尝试测试我的 saga,但我在测试 select 时遇到了一些问题。

我想从 reselect 模拟 createSelector,但我不能这样做,因为我有这个错误:

Cannot read property \'module\' of undefined

我重新选择:

//R - is ramda

export const selectFilters = createSelector(R.path(['notification', 'filters']), (filters) => filters)

我的传奇:

//module gives me error because selectFilters returns undefined

const {module, orderByDate} = yield select(selectors.selectFilters())

您必须将选择器的引用传递给 select 效果。在您的传奇中,您实际上是在调用选择器,然后传递 return 值。如果操作得当,则不必模拟选择器。

像这样修改您的代码以修复错误:

const {module, orderByDate} = yield select(selectors.selectFilters)