-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ErrorObservable): Added and fixed failing test for Observable.catch #2552
fix(ErrorObservable): Added and fixed failing test for Observable.catch #2552
Conversation
49dae47
to
a5e9c33
Compare
f9a64c6
to
4e2a978
Compare
spec/operators/catch-spec.ts
Outdated
let timers: sinon.SinonFakeTimers; | ||
|
||
let source: Rx.Observable<any>; | ||
beforeEach(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are a little too DRY for my liking. Prefer doing as much set up as possible in each test.
Also, I'll be honest, I'm not at all familar with sinon.sandbox. I'll need to research it to see if it's an approach we want to use. I presume it's some virtualized scheduling thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @benlesh, thanks for taking a look at this PR. I'll update the tests to be more explicit per test and get back to you. I used sinon.sandbox as I found other examples in the current test suite: https://github.com/ReactiveX/rxjs/search?utf8=%E2%9C%93&q=sinon.sandbox&type=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have few cases of using it, but in general if it can be avoided try not to use it. except some obvious cases (like test scheduler), usually test for Rx can be written without sandbox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the source observable from the setup block and into each test.
4e2a978
to
0f4bb92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want a response on given feedback
@@ -278,4 +279,83 @@ describe('Observable.prototype.catch', () => { | |||
done(); | |||
}); | |||
}); | |||
|
|||
context('fromPromise', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is a nitpick... but everywhere else I think we use describe
. I didn't even know context
is a thing. Is there a reason this is better in this case than describe
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to change it to describe
, didn't realize there are no other usages of context
in the test suite. I personally have used context
to mean "a different approach to call the same feature" where describe
is a "different feature". There is no difference in functionality.
describe('functionA', () => {
context('success', () => {...});
context('error', () => {...});
});
Documentation: https://mochajs.org/#bdd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's fine I think.
Thanks, @trshafer! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description:
Added a failing test describing unexpected behavior between throw Error and Observable.throw(Error) when the source of an observable is a Promise. In my opinion this behavior is confusing as the catch handler needs to know if the source is from a Promise vs another source. Thanks for taking a look.
Added fix by forcing
sync.syncErrorThrowable
onErrorObservable
. Let me know if this is a good fix and if I should add a unit test for ErrorObservable.Related issue (if exists):
Related #2485.