unit testing using jasmine marbles

1.5k Views Asked by At

I am trying to do a simple test using jasmine-marbles but getting errors

This is my test code:

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);
  })   

});

and this is the error I am getting:

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"}}],

if I use the jest framework, the above code works, but I want to get it working withe default test framework that comes with Angular setup

Any help to sort this error is appreciated Thanks

2

There are 2 best solutions below

0
user2144132 On BEST ANSWER

Try checking the jasmine-marbles version.

I experienced the same issue with using "jasmine-marbles": "^0.9.0" with "rxjs": "^6.6.7".

Downgrading to "jasmine-marbles": "^0.8.0" resolved the issue.

See supported versions here: https://github.com/synapse-wireless-labs/jasmine-marbles#readme

2
dimaslz On

I don't know if can help you but I had the same issue testing effects and I fixed it using https://ngrx.io/guide/effects/testing#with-testscheduler. I think the last versions of jasmine-marbles are not aligned with rxjs.

I hope could be helpful for you.