ReactiveX / rxjs

A reactive programming library for JavaScript
https://rxjs.dev
Apache License 2.0
30.6k stars 3k forks source link

Migration guide: Testing asynchronous error handling #3939

Open molily opened 6 years ago

molily commented 6 years ago

Documentation Related To Component:

https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md

Please check those that apply

Description Of The Issue

Regarding this example code:

it('should emit an error on subscription', (done) => {
  source$.subscribe({
    error(err) {
      expect(err.message).toEqual('some message');
    }
  });
});

The done function is mentioned but not used. It should be called at least:

it('should emit an error on subscription', (done) => {
  source$.subscribe({
    error(err) {
      expect(err.message).toEqual('some message');
      done();
    }
  });
});

This would work, but there is still the problem that this test times out instead of failing instantly when the Observable emits a value instead of throwing an error.

In Jasmine, something like this would be better, wouldn’t it?

it('should emit an error on subscription', (done) => {
  source$.subscribe(
    done.fail,
    (err) => {
      expect(err.message).toEqual('some message');
      done();
    }
  });
});
BioPhoton commented 5 years ago

Due to the creation date and missing responses for so long, I assume we can close this one. @cartant please let me know if I'm wrong

cartant commented 5 years ago

@biophoton If the problem is still there and hasn't been addressed, we should fix it. The lack of responses should just been seen as people being busy with other, higher-prioriity tasks, that's all.

BioPhoton commented 5 years ago

Thx @cartant!

Just to make it clear, my intention here is not to put pressure in it. What I try is find old issues that could get closed.

I will consider your answer in further comments! 🙏🙏🙏❤️