Que*_*ing 2 jasmine angular jasmine-marbles
我有一个人们可以在这里下载的快速演示:https://stackblitz.com/edit/angular-vczzqp只需点击右上角的导出,在您最喜欢的终端中运行install并ng test使用您喜欢的浏览器.
对我来说,基本上问题似乎是Jasmine的内部时间与对象不匹配.
下面是测试以及我得到的确切错误.请参阅app/Test下的示例以获取完整的测试类
it('should return a GET_GENERIC_FAILED when the services throws', () => {
const action = new genericActions.GetAllGenericAction();
genericsService.getAllGenerics.and.returnValue(Observable.throw({}));
actions$.stream = hot('a', { a: action });
const expected = cold('b', { b: new genericActions.GetGenericFailedAction() });
expect(effects.getAllGenerics).toBeObservable(expected);
});
Run Code Online (Sandbox Code Playgroud)
而错误
Expected
[Object({
frame: 0,
notification: Notification({
kind: 'N',
value: GetGenericFailedAction({
type: '[GENERIC] Get Generic Failed'
}),
error: undefined,
hasValue: true
})
}), Object({
frame: 0,
notification: Notification({
kind: 'C',
value: undefined,
error: undefined,
hasValue: false
})
})]
to equal
[Object({
frame: 0,
notification: Notification({
kind: 'N',
value: GetGenericFailedAction({
type: '[GENERIC] Get Generic Failed'
}),
error: undefined,
hasValue: true
})
})].
Run Code Online (Sandbox Code Playgroud)
任何指导将不胜感激.
Que*_*ing 12
看起来这是一个关于如何抛出错误的问题.
修复是添加|以将observable标记为已完成以及将预期的observable包装()在一起以将操作分组.
actions$.stream = hot('a|', { a|: action });
const expected = cold('(b|)', { b: new genericActions.GetGenericFailedAction() });
Run Code Online (Sandbox Code Playgroud)
有关语法的文档在这里.
| 归档时间: |
|
| 查看次数: |
2512 次 |
| 最近记录: |