-
-
Notifications
You must be signed in to change notification settings - Fork 306
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 stack where actual==falsy #400
Conversation
lib/results.js
Outdated
@@ -157,7 +157,7 @@ function encodeResult (res, count) { | |||
output += inner + 'at: ' + res.at + '\n'; | |||
} | |||
|
|||
var actualStack = res.actual && res.actual.stack; | |||
var actualStack = res.actual !== undefined && res.actual.stack; |
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 will cause it to throw if res.actual
is null
.
If res.actual
is a primitive (even a truthy primitive), .stack
will never have a meaningful value.
This check should probably really be res.actual && (typeof res.actual === 'object' || typeof res.actual === 'function') ? res.actual.stack : null
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'm working slightly [confused] here, on windows a lot of the unit tests fail. Will update the pr.
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, I see. It was working on my machine for the wrong reason. The actual bug is:
when res.actual === false,
(res.actual && res.actual.stack) === false, not undefined
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.
@nhamer fyi, i edited your comment to remove the inappropriate word.
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.
Thanks for the clarification. Could you provide a test that would fail without this change?
it was the inverse of the existing test; fixed the existing test's assertion to accurately reflect its arguments |
6bcc7f5
to
10b7dcd
Compare
- [New] use `process.env.NODE_TAPE_OBJECT_PRINT_DEPTH` for the default object print depth (#420) - [New] Add "onFailure" listener to test harness (#408) - [Fix] fix stack where actual is falsy (#400) - [Fix] normalize path separators in stacks (#402) - [Fix] fix line numbers in stack traces from inside anon functions (#387) - [Fix] Fix dirname in stack traces (#388) - [Robustness] Use local reference for clearTimeout global (#385) - [Deps] update `function-bind`
Fixes #399