Skip to content

Commit 8180357

Browse files
authored
Reporter: TapReporter align actual with expected
When comparing two strings, it is significantly easier to spot the difference when they are aligned. This change pads the label for `actual` with a couple of spaces so that the actual value is printed at the same indentation as the expected value. Previously the expected value was right shifted by 2 characters... Closes #107.
1 parent 634b6b9 commit 8180357

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/reporters/TapReporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default class TapReporter {
4848

4949
if (error.hasOwnProperty('actual')) {
5050
var actualStr = error.actual !== undefined ? ('"' + JSON.stringify(error.actual, null, 2).replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"') : 'undefined'
51-
console.log(` actual: ${actualStr}`)
51+
console.log(` actual : ${actualStr}`)
5252
}
5353

5454
if (error.hasOwnProperty('expected')) {

test/unit/tap-reporter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ describe('Tap reporter', function () {
8585

8686
emitter.emit('testEnd', data.actualUndefinedTest)
8787

88-
expect(spy).to.have.been.calledWith(' actual: undefined')
88+
expect(spy).to.have.been.calledWith(' actual : undefined')
8989
}))
9090

9191
it('should output actual value for failed assertions even it was falsy', sinon.test(function () {
9292
var spy = this.stub(console, 'log')
9393

9494
emitter.emit('testEnd', data.actualFalsyTest)
9595

96-
expect(spy).to.have.been.calledWith(' actual: "0"')
96+
expect(spy).to.have.been.calledWith(' actual : "0"')
9797
}))
9898

9999
it('should output expected value for failed assertions even it was undefined', sinon.test(function () {

0 commit comments

Comments
 (0)