我已经为我的传奇写了一些磁带测试,但最简单的例子却因为同样的原因而一直失败。我有一行传奇:
export function* clearUser(){
yield* put({type: 'CLEAR_USER'});
}
我的磁带测试同样简单:
test('clear user saga', (assert)=> {
const gen = clearUser();
assert.deepEqual(
gen.next().value,
put({type: 'CLEAR_USER'}),
'clear user should pass to reducer to remove user from state'
)
assert.deepEqual(
gen.next(),
{ done: true, value: undefined },
'clear user saga should complete'
)
assert.end()
});
然而,第一个断言失败并且表示值未定义:
operator: deepEqual
expected: |-
{ '@@redux-saga/IO': true, PUT: { action: { type: 'CLEAR_USER' }, channel: null } }
actual: |-
undefined
我已经确认我导入了传奇,其他测试正在运行,为什么这个简单的测试会失败?