Skip to content
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

feat: add file path to xunit reporter #4985

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/reporters/xunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ XUnit.prototype.test = function (test) {
var attrs = {
classname: test.parent.fullTitle(),
name: test.title,
file: test.file,
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
time: test.duration / 1000 || 0
};

Expand Down
11 changes: 11 additions & 0 deletions test/reporters/xunit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ';
Expand Down Expand Up @@ -325,6 +326,7 @@ describe('XUnit reporter', function () {
var expectedTest = {
state: STATE_FAILED,
title: expectedTitle,
file: expectedFile,
parent: {
fullTitle: function () {
return expectedClassName;
Expand All @@ -347,6 +349,8 @@ describe('XUnit reporter', function () {
expectedClassName +
'" name="' +
expectedTitle +
'" file="' +
expectedFile +
'" time="1"><failure>' +
expectedMessage +
'\n' +
Expand All @@ -365,6 +369,7 @@ describe('XUnit reporter', function () {
var expectedTest = {
state: STATE_FAILED,
title: expectedTitle,
file: expectedFile,
parent: {
fullTitle: function () {
return expectedClassName;
Expand Down Expand Up @@ -402,6 +407,7 @@ describe('XUnit reporter', function () {
return true;
},
title: expectedTitle,
file: expectedFile,
parent: {
fullTitle: function () {
return expectedClassName;
Expand All @@ -418,6 +424,8 @@ describe('XUnit reporter', function () {
expectedClassName +
'" name="' +
expectedTitle +
'" file="' +
expectedFile +
'" time="1"><skipped/></testcase>';
expect(expectedWrite, 'to be', expectedTag);
});
Expand All @@ -431,6 +439,7 @@ describe('XUnit reporter', function () {
return false;
},
title: expectedTitle,
file: expectedFile,
parent: {
fullTitle: function () {
return expectedClassName;
Expand All @@ -447,6 +456,8 @@ describe('XUnit reporter', function () {
expectedClassName +
'" name="' +
expectedTitle +
'" file="' +
expectedFile +
'" time="0"/>';
expect(expectedWrite, 'to be', expectedTag);
});
Expand Down