From a91e86cfe50efa2208dd582e3c346739ccaecb72 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Wed, 11 May 2022 13:07:34 -0400 Subject: [PATCH 1/3] feat: add file path to xunit reporter --- lib/reporters/xunit.js | 1 + test/reporters/xunit.spec.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js index ec788c5da0..4e6fe2bcf9 100644 --- a/lib/reporters/xunit.js +++ b/lib/reporters/xunit.js @@ -158,6 +158,7 @@ XUnit.prototype.test = function (test) { var attrs = { classname: test.parent.fullTitle(), name: test.title, + file: test.file, time: test.duration / 1000 || 0 }; diff --git a/test/reporters/xunit.spec.js b/test/reporters/xunit.spec.js index a5e0f1bbeb..4e98cf6002 100644 --- a/test/reporters/xunit.spec.js +++ b/test/reporters/xunit.spec.js @@ -30,6 +30,7 @@ describe('XUnit reporter', function () { var expectedLine = 'some-line'; var expectedClassName = 'fullTitle'; var expectedTitle = 'some title'; + var expectedFile = 'testFile.spec.js'; var expectedMessage = 'some message'; var expectedDiff = '\n + expected - actual\n\n -foo\n +bar\n '; @@ -325,6 +326,7 @@ describe('XUnit reporter', function () { var expectedTest = { state: STATE_FAILED, title: expectedTitle, + file: expectedFile, parent: { fullTitle: function () { return expectedClassName; @@ -347,6 +349,8 @@ describe('XUnit reporter', function () { expectedClassName + '" name="' + expectedTitle + + '" file="' + + expectedFile + '" time="1">' + expectedMessage + '\n' + @@ -365,6 +369,7 @@ describe('XUnit reporter', function () { var expectedTest = { state: STATE_FAILED, title: expectedTitle, + file: expectedFile, parent: { fullTitle: function () { return expectedClassName; @@ -402,6 +407,7 @@ describe('XUnit reporter', function () { return true; }, title: expectedTitle, + file: expectedFile, parent: { fullTitle: function () { return expectedClassName; @@ -418,6 +424,8 @@ describe('XUnit reporter', function () { expectedClassName + '" name="' + expectedTitle + + '" file="' + + expectedFile + '" time="1">'; expect(expectedWrite, 'to be', expectedTag); }); @@ -431,6 +439,7 @@ describe('XUnit reporter', function () { return false; }, title: expectedTitle, + file: expectedFile, parent: { fullTitle: function () { return expectedClassName; @@ -447,6 +456,8 @@ describe('XUnit reporter', function () { expectedClassName + '" name="' + expectedTitle + + '" file="' + + expectedFile + '" time="0"/>'; expect(expectedWrite, 'to be', expectedTag); }); From 1245e7e80f3d9faed99d459dcfebdb35d31be370 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:03:52 -0400 Subject: [PATCH 2/3] Update lib/reporters/xunit.js Co-authored-by: Ville Lahdenvuo --- lib/reporters/xunit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js index 4e6fe2bcf9..b4217ffb23 100644 --- a/lib/reporters/xunit.js +++ b/lib/reporters/xunit.js @@ -158,7 +158,7 @@ XUnit.prototype.test = function (test) { var attrs = { classname: test.parent.fullTitle(), name: test.title, - file: test.file, + file: test.file || test?.invocationDetails?.absoluteFile, time: test.duration / 1000 || 0 }; From 4a48a8f88277a1a2704f5ba6cda0aed47adc2fb6 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:07:43 -0400 Subject: [PATCH 3/3] Revert "Update lib/reporters/xunit.js" This reverts commit 1245e7e80f3d9faed99d459dcfebdb35d31be370. --- lib/reporters/xunit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js index b4217ffb23..4e6fe2bcf9 100644 --- a/lib/reporters/xunit.js +++ b/lib/reporters/xunit.js @@ -158,7 +158,7 @@ XUnit.prototype.test = function (test) { var attrs = { classname: test.parent.fullTitle(), name: test.title, - file: test.file || test?.invocationDetails?.absoluteFile, + file: test.file, time: test.duration / 1000 || 0 };