This repository was archived by the owner on Jun 18, 2021. It is now read-only.
Open
Conversation
… "TypeError: Cannot read property 'on' of undefined"
teogeb
approved these changes
Apr 20, 2021
harbu
reviewed
Apr 20, 2021
| }) | ||
| stream.on('error', (err) => { | ||
| try { | ||
| let delimiter = '' |
Contributor
There was a problem hiding this comment.
If stream.on is failing, it seems like a fundamental problem with the code that should cause a crash instead of being wrapped in a 500 error code and sent back to client? I.e. it is an unexpected error that should not really ever occur unless there is a problem with our code.
| it('responds 500 and error message if networkNode signals error', (done) => { | ||
| networkNode.requestResendRange = () => intoStream.object(Promise.reject(new Error('error'))) | ||
| it('responds 500 and error message if networkNode signals error', async () => { | ||
| networkNode.requestResendRange = jest.fn(() => intoStream.object(Promise.reject(new Error('expected error')))) |
Contributor
There was a problem hiding this comment.
What's the reasoning behind wrapping the function with jest.fn if it not being asserted (e.g. num of calls)?
Contributor
Author
There was a problem hiding this comment.
just consistency really, jest.fn also signals (to me at least) that this is a mock function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes distracting and unnecessary
TypeErrorissues reported in tests.Also converts the
supertesttests to useasync/awaitinstead of Jest'sdonecallback.Shouldn't conflict with #238