mercredi 7 août 2019

RxJs marble testing retryWhen

I have a SocketService. This class is responsible for socket connection and messaging with a server. I've written some code to make my client able to reconnect on connection loss. It should make 3 attempts with 5 sec delay between them and if no success redirect to login page.

After that I've written a test but I cannot make it work even close to what happening.

I'm trying to simulate 2 errors on send and one successful message. What should result in 3 reconnect attempts and the last successful one.

Here is my test https://stackblitz.com/edit/jasmine-marbles-testing-jdvcnm?file=src/test.spec.ts

I expect a marble diagram to be something near -# 5s # 5s (a|) (in test there is another diagram since I tried different ones).

Aucun commentaire:

Enregistrer un commentaire