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

Update: Include files with no messages in junit results (#9093) #9094

Merged
merged 1 commit into from
Aug 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions lib/formatters/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ module.exports = function(results) {

const messages = result.messages;

if (messages.length) {
output += `<testsuite package="org.eslint" time="0" tests="${messages.length}" errors="${messages.length}" name="${result.filePath}">\n`;
}

output += `<testsuite package="org.eslint" time="0" tests="${messages.length}" errors="${messages.length}" name="${result.filePath}">\n`;
messages.forEach(message => {
const type = message.fatal ? "error" : "failure";

Expand All @@ -57,10 +54,7 @@ module.exports = function(results) {
output += `</${type}>`;
output += "</testcase>\n";
});

if (messages.length) {
output += "</testsuite>\n";
}
output += "</testsuite>\n";

});

Expand Down
6 changes: 3 additions & 3 deletions tests/lib/formatters/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe("formatter:junit", () => {
});
});

describe("when passed multiple files with total 1 failure", () => {
describe("when passed multiple files should print even if no errors", () => {
const code = [{
filePath: "foo.js",
messages: [{
Expand All @@ -192,10 +192,10 @@ describe("formatter:junit", () => {
messages: []
}];

it("should return 1 <testsuite>", () => {
it("should return 2 <testsuite>", () => {
const result = formatter(code);

assert.equal(result.replace(/\n/g, ""), "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites><testsuite package=\"org.eslint\" time=\"0\" tests=\"1\" errors=\"1\" name=\"foo.js\"><testcase time=\"0\" name=\"org.eslint.foo\"><failure message=\"Unexpected foo.\"><![CDATA[line 5, col 10, Warning - Unexpected foo. (foo)]]></failure></testcase></testsuite></testsuites>");
assert.equal(result.replace(/\n/g, ""), "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites><testsuite package=\"org.eslint\" time=\"0\" tests=\"1\" errors=\"1\" name=\"foo.js\"><testcase time=\"0\" name=\"org.eslint.foo\"><failure message=\"Unexpected foo.\"><![CDATA[line 5, col 10, Warning - Unexpected foo. (foo)]]></failure></testcase></testsuite><testsuite package=\"org.eslint\" time=\"0\" tests=\"0\" errors=\"0\" name=\"bar.js\"></testsuite></testsuites>");
});
});
});