-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Make sure invalid jest-each points to user code #6347
Conversation
packages/jest-each/src/bind.js
Outdated
'\n\n' + | ||
`Missing ${RECEIVED_COLOR(`${data.length % keys.length}`)} arguments`, | ||
); | ||
|
||
return cb(title, () => { |
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.
@mattphillips the idea is to create the error within the same async tick as the method call from the user - the moment you cross an async barrier (like executing the body of a test) the original stack is lost
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.
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.
throwing a string instead of a new error would probably work as well, as we'd discover there was no stack, and use the one we keep around for async errors. Throwing an error though gives us a stack - it just doesn't point to user code
packages/jest-each/src/bind.js
Outdated
'Received:\n' + | ||
RECEIVED_COLOR(pretty(data)) + | ||
'\n\n' + | ||
`Missing ${RECEIVED_COLOR(`${data.length % keys.length}`)} arguments`, |
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.
last s
here should be gone, when 1
. We've got a pluralize
helper or two sticking around somewhere
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.
Want me to send a PR for this? I can't amend this branch ;)
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 please 🙂
10 | \${true} | \${true} | ||
11 | \${true} | | ||
|
||
at packages/jest-each/build/bind.js:80:23 |
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.
Would be lovely if we could strip this internal call
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.
That would be awesome!
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 2 or 3 layers up, so a bit painful (we'd have to create the error in index
and pass it into bind
)
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.
HAH, I lied. Pushed 🙂
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 so freaking cool! Amazing stuff @SimenB ❤️ |
Codecov Report
@@ Coverage Diff @@
## master #6347 +/- ##
==========================================
+ Coverage 63.63% 63.64% +0.01%
==========================================
Files 226 226
Lines 8648 8651 +3
Branches 4 4
==========================================
+ Hits 5503 5506 +3
Misses 3144 3144
Partials 1 1
Continue to review full report at Codecov.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
On invalid Each argument, point back to the actual invocation of
each
from user code./cc @mattphillips
Test plan
Updated test