-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Exposes generation of diffs from base reporter #3213
Conversation
Looks good to me. @harrysarson thanks! |
I'll update IntelliJ reporter once the PR is merged. |
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 looks good, thanks @harrysarson. I just have a couple nitpicks.
@segrey To make sure I'm not missing something, can you clarify what you meant about err.details
back in #3201?
lib/reporters/base.js
Outdated
var generateDiff = exports.generateDiff = function (actual, expected) { | ||
if (exports.inlineDiffs) { | ||
return inlineDiff(actual, expected); | ||
} else { |
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 else
is not necessary
lib/reporters/base.js
Outdated
* The diff will be either inline or unified dependant on the value | ||
* of `Base.inlineDiff`. | ||
* | ||
* @api private |
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 think the intent is that this is a public function, so you can remove this, right?
lib/reporters/base.js
Outdated
* of `Base.inlineDiff`. | ||
* | ||
* @api private | ||
* @param {String} actual |
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.
lowercase string
test/reporters/base.spec.js
Outdated
var oldInlineDiffs = Base.inlineDiffs; | ||
Base.inlineDiffs = false; | ||
|
||
var output = Base.generateDiff(actual, expected); |
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.
please do the patching in a beforeEach
of the suite and restore in afterEach
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.
When doing the patching, should I be setting the value of Base.inlineDiffs
in the beforeEach
?
@harrysarson Thanks for this!! in the future, please just reuse your PRs and force-push changes--it's kind of difficult to track the conversation otherwise |
@boneskull Regarding
As a benefit, mocha will have a mechanism to easily change how these values are calculated, e.g. supply diffs provided by assertion libraries without changes in reporters. |
I have hopefully made all the requested changes :)
Ah yeah, I will in future. |
Now fixed |
e159bf1
to
f90a3ce
Compare
@boneskull can this be merged or is more work needed, I think I have resolved all the required changes :) |
@segrey Got it. So it looks like this PR is the first step to get there. |
blah, meant to squash. |
Second attempt at solution for #3011, improves on PR #3201.
PR based on suggestion by @segrey in #3201 (comment). Exposed function
generateDiff(expected, actual)
as a static member ofBase
.The value of
Base.inlineDiffs
is used to determine the form of the diff.Alternate Designs
#3201
Why should this be in core?
Allows IDE's to produce nice output when integrated with mocha.
Benefits
See #3011.