私はサガ内でcatchステートメントをテストしようとするときに問題があります。私は、コンソールに出力されたError: error
で以下のテストに失敗している、Mochaとchaiを使用しています。redux-sagaでtry-catchをテストします
saga.js
function* submitCredentials(action) {
try {
} catch(e) {
yield put({type: LOGIN_FAIL, message: e.message})
}
}
test.js
it('should catch errors',() => {
const generator = submitCredentials();
const error = new Error('error');
expect(generator.throw(error).value, put({
type: actions.LOGIN_FAIL, error
}));
});
が期待行が期待 'である必要はありません(generator.throw(エラー).VALUE).to.equal((置く{ タイプ:actions.LOGIN_FAIL、 'エラー' を}));' – BarthesSimpson
か(タイプ:actions.LOGIN_FAIL、{message: 'error'} )))); – BarthesSimpson