使用 toBeObservable() 时,Jasmine 测试在 RxJS 7 中总是失败
Jasmine tests always failing in RxJS 7 when using toBeObservable()
我已经更新了我的依赖项,现在我遇到了这个错误消息:
DEPRECATION: The matcher factory for "toBeObservable" accepts custom equality testers, but this parameter will no longer be passed in a future release. See <https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#matchers-cet> for details.
Error: Expected $[0].notification to be a kind of Object, but was Notification({ kind: 'N', value: true, error: undefined, hasValue: true }).
at <Jasmine>
at toBeObservableComparer (node_modules/jasmine-marbles/es6/index.js:80:1)
at <Jasmine>
测试很简单:
const expected = cold('a', {a: true});
expect(new BehaviorSubject(true)).toBeObservable(expected);
这可能与弃用通知有关,但我只是使用最新版本的 jasmine-marbles
包中的 toBeObservable()
,看不到自定义参数。我也不明白为什么 Notification
不是一种 Object
.
版本:
- rxjs: 7.5.2
- 茉莉花核心:4.0.0
- 茉莉花弹珠:0.8.4
- 业力茉莉花:4.0.1
该脚本适用于 rxjs 6.6.7。
我认为新文档显示了新的 expectObservable:
expectObservable(new BehaviorSubject(true).asObservable()).toBe(expected);
我已经更新了我的依赖项,现在我遇到了这个错误消息:
DEPRECATION: The matcher factory for "toBeObservable" accepts custom equality testers, but this parameter will no longer be passed in a future release. See <https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#matchers-cet> for details.
Error: Expected $[0].notification to be a kind of Object, but was Notification({ kind: 'N', value: true, error: undefined, hasValue: true }).
at <Jasmine>
at toBeObservableComparer (node_modules/jasmine-marbles/es6/index.js:80:1)
at <Jasmine>
测试很简单:
const expected = cold('a', {a: true});
expect(new BehaviorSubject(true)).toBeObservable(expected);
这可能与弃用通知有关,但我只是使用最新版本的 jasmine-marbles
包中的 toBeObservable()
,看不到自定义参数。我也不明白为什么 Notification
不是一种 Object
.
版本:
- rxjs: 7.5.2
- 茉莉花核心:4.0.0
- 茉莉花弹珠:0.8.4
- 业力茉莉花:4.0.1
该脚本适用于 rxjs 6.6.7。
我认为新文档显示了新的 expectObservable:
expectObservable(new BehaviorSubject(true).asObservable()).toBe(expected);