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.
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 eval setCurrentStory error + make logging better #837
🐛 ✨Fix eval setCurrentStory error + make logging better #837
Changes from 4 commits
c76d9ec
36a5dce
d55f7c0
254b326
6376d33
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Do we get original error passed to us, if yes we can wrap and rethrow it
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.
Even tried -
But this again resulted in -
[percy] TypeError: Cannot read properties of undefined (reading 'message')
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.
Oh, just learned something new about JS which explains this better.
Whenever a function name is passed as callback, it calls the function by whatever parameters are passed.
So, in this case
This would call reject with whatever parameters are passed to eventListener, and since nothing is passed, hence we reject with
undefined
resulting in above error.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.
so basically story missing isnt passing anything ...
Also its not a new thing, its a standard thing that works across almost all languages ( except where brackets are not required for a function call, Ruby 👀 ), it works because its no different, it expects a function and you are passing a function
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.
yes
Wasn't aware of this, thanks!
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.
Word change ? Is this same for v6 and v7
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.
This is a custom error that we are throwing.Earlier in the test itself, we were mocking the error to be thrown, since
storyErrored
event was caught, but wereject
the promise and passed nothing to it, so it returned undefined and fell back to the mocked error.Okay, now I understand this a little better.
Earlier we were calling
c
(callback) withnew Error('Story Error')
This would result in
reject
being called with thenew Error('Story Error')
, but since we have seen circumstances where nothing is passed to the callback which results in rejection withundefined
, and hence added a custom message ofStory Errored
, instead of relying on default arguments.Edit: Updated the mock to execute callback with no arguments, instead of
new Error('Story Error')
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.
Refactored error throwing logic, so as to not update tests.