-
-
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,16 +34,18 @@ export default (cb: Function) => (...args: any) => ( | |
const table = buildTable(data, keys.length, keys); | ||
|
||
if (data.length % keys.length !== 0) { | ||
const error = new Error( | ||
'Not enough arguments supplied for given headings:\n' + | ||
EXPECTED_COLOR(keys.join(' | ')) + | ||
'\n\n' + | ||
'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 commentThe reason will be displayed to describe this comment to others. Learn more. last There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. yes please 🙂 |
||
); | ||
|
||
return cb(title, () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 |
||
throw new Error( | ||
'Not enough arguments supplied for given headings:\n' + | ||
EXPECTED_COLOR(keys.join(' | ')) + | ||
'\n\n' + | ||
'Received:\n' + | ||
RECEIVED_COLOR(pretty(data)) + | ||
'\n\n' + | ||
`Missing ${RECEIVED_COLOR(`${data.length % keys.length}`)} arguments`, | ||
); | ||
throw 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.
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 intobind
)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 🙂