Skip to content

Commit a787e39

Browse files
jebergerKrinkle
authored andcommitted
Revert "Reporter: Fix YAML output in TAP reporter (#110)"
This turns too many values into quoted JSON strings, which makes the output difficult to read. I am reverting this for 1.x-stable to allow other changes to be released and adopted by consumers, such as QUnit. I will improve on the solution in a different way in master for js-reporters 2.0. Ref #109.
1 parent 8180357 commit a787e39

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/reporters/TapReporter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ export default class TapReporter {
4343

4444
logError (error, severity) {
4545
console.log(' ---')
46-
console.log(` message: "${(error.message || 'failed').replace(/"/g, '\\"')}"`)
46+
console.log(` message: "${error.message || 'failed'}"`)
4747
console.log(` severity: ${severity || 'failed'}`)
4848

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

5454
if (error.hasOwnProperty('expected')) {
55-
var expectedStr = error.expected !== undefined ? ('"' + JSON.stringify(error.expected, null, 2).replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"') : 'undefined'
55+
var expectedStr = error.expected !== undefined ? JSON.stringify(error.expected, null, 2) : 'undefined'
5656
console.log(` expected: ${expectedStr}`)
5757
}
5858

5959
if (error.stack) {
60-
console.log(` stack: "${error.stack.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"`)
60+
console.log(` stack: ${error.stack}`)
6161
}
6262

6363
console.log(' ...')

test/unit/tap-reporter.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ describe('Tap reporter', function () {
6868

6969
data.failingTest.errors.forEach(function (error) {
7070
expected.push(' ---')
71-
expected.push(' message: "' + error.message.replace(/"/g, '\\"') + '"')
71+
expected.push(' message: "' + error.message + '"')
7272
expected.push(' severity: failed')
73-
expected.push(' stack: "' + error.stack.replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"')
73+
expected.push(' stack: ' + error.stack)
7474
expected.push(' ...')
7575
})
7676

7777
emitter.emit('testEnd', data.failingTest)
78+
7879
for (var i = 0; i < expected.length; i++) {
7980
expect(spy).to.have.been.calledWith(expected[i])
8081
}
@@ -93,7 +94,7 @@ describe('Tap reporter', function () {
9394

9495
emitter.emit('testEnd', data.actualFalsyTest)
9596

96-
expect(spy).to.have.been.calledWith(' actual : "0"')
97+
expect(spy).to.have.been.calledWith(' actual : 0')
9798
}))
9899

99100
it('should output expected value for failed assertions even it was undefined', sinon.test(function () {
@@ -109,7 +110,7 @@ describe('Tap reporter', function () {
109110

110111
emitter.emit('testEnd', data.expectedFalsyTest)
111112

112-
expect(spy).to.have.been.calledWith(' expected: "0"')
113+
expect(spy).to.have.been.calledWith(' expected: 0')
113114
}))
114115

115116
it('should output the total number of tests', sinon.test(function () {

0 commit comments

Comments
 (0)