0

我正在尝试使用jasmine-marbles但出现错误进行简单测试

这是我的测试代码:

describe('MarbleTestingComponent', () => {
  it('should test marble syntax', () => {
    const provided = search('e');
    const expected = cold('(e|)', {e: 'e'});
    console.log(expected, provided);
    expect(provided).toBeObservable(expected);
  })   

});

这是我得到的错误:

Error: 
            Expected: (e|),
            Received: (?|),
            
            Expected:
            [{"frame":0,"notification":{"kind":"N","value":"e","hasValue":true}},{"frame":0,"notification":{"kind":"C","hasValue":false}}]
            
            Received:
            [{"frame":0,"notification":{"kind":"N","value":"e"}},{"frame":0,"notification":{"kind":"C"}}],

如果我使用jest框架,上面的代码可以工作,但我想让它与 Angular 设置附带的默认测试框架一起工作

感谢您对解决此错误的任何帮助谢谢

4

2 回答 2

3

尝试检查 jasmine-marbles 版本。

我在使用“jasmine-marbles”:“^0.9.0”和“rxjs”:“^6.6.7”时遇到了同样的问题。

降级到 "jasmine-marbles": "^0.8.0" 解决了这个问题。

在此处查看支持的版本:https ://github.com/synapse-wireless-labs/jasmine-marbles#readme

于 2021-07-02T15:08:19.313 回答
0

我不知道是否可以帮助你,但我在测试效果时遇到了同样的问题,我使用https://ngrx.io/guide/effects/testing#with-testscheduler修复了它。我认为 jasmine-marbles 的最新版本与 rxjs 不一致。

我希望能对你有所帮助。

于 2021-09-13T20:52:49.463 回答