From 293f50d57d0fa4e146ebace23fc94ec9d11fa684 Mon Sep 17 00:00:00 2001 From: Marc Udoff Date: Tue, 26 Jun 2018 13:24:23 -0400 Subject: [PATCH] Show diff in xunit --- lib/reporters/xunit.js | 8 +++++++- test/reporters/xunit.spec.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js index c1a930d2d8..bd89a37e76 100644 --- a/lib/reporters/xunit.js +++ b/lib/reporters/xunit.js @@ -151,6 +151,8 @@ XUnit.prototype.write = function(line) { * @param {Test} test */ XUnit.prototype.test = function(test) { + Base.useColors = false; + var attrs = { classname: test.parent.fullTitle(), name: test.title, @@ -159,6 +161,10 @@ XUnit.prototype.test = function(test) { if (test.state === 'failed') { var err = test.err; + var diff = + Base.hideDiff || !err.actual || !err.expected + ? '' + : '\n' + Base.generateDiff(err.actual, err.expected); this.write( tag( 'testcase', @@ -168,7 +174,7 @@ XUnit.prototype.test = function(test) { 'failure', {}, false, - escape(err.message) + '\n' + escape(err.stack) + escape(err.message) + escape(diff) + '\n' + escape(err.stack) ) ) ); diff --git a/test/reporters/xunit.spec.js b/test/reporters/xunit.spec.js index 8108c50b78..42e9ca2c6e 100644 --- a/test/reporters/xunit.spec.js +++ b/test/reporters/xunit.spec.js @@ -18,6 +18,8 @@ describe('XUnit reporter', function() { var expectedClassName = 'fullTitle'; var expectedTitle = 'some title'; var expectedMessage = 'some message'; + var expectedDiff = + '\n + expected - actual\n\n -foo\n +bar\n '; var expectedStack = 'some-stack'; var expectedWrite = null; @@ -214,6 +216,8 @@ describe('XUnit reporter', function() { }, duration: 1000, err: { + actual: 'foo', + expected: 'bar', message: expectedMessage, stack: expectedStack } @@ -235,6 +239,8 @@ describe('XUnit reporter', function() { '" time="1">' + expectedMessage + '\n' + + expectedDiff + + '\n' + expectedStack + '';