diff --git a/lib/formatters/junit.js b/lib/formatters/junit.js index 77d548f380e2..1a66229cedde 100644 --- a/lib/formatters/junit.js +++ b/lib/formatters/junit.js @@ -5,6 +5,7 @@ "use strict"; const xmlEscape = require("../util/xml-escape"); +const path = require("path"); //------------------------------------------------------------------------------ // Helper Functions @@ -38,13 +39,14 @@ module.exports = function(results) { results.forEach(result => { const messages = result.messages; + const classname = path.basename(result.filePath, path.extname(result.filePath)); if (messages.length > 0) { output += `\n`; messages.forEach(message => { const type = message.fatal ? "error" : "failure"; - output += ``; + output += ``; output += `<${type} message="${xmlEscape(message.message || "")}">`; output += "\n"; } else { output += `\n`; - output += `\n`; + output += `\n`; output += "\n"; } diff --git a/tests/lib/formatters/junit.js b/tests/lib/formatters/junit.js index 5a8340c3bcb7..1c63d22ff8c3 100644 --- a/tests/lib/formatters/junit.js +++ b/tests/lib/formatters/junit.js @@ -31,7 +31,7 @@ describe("formatter:junit", () => { describe("when passed a single message", () => { const code = [{ - filePath: "foo.js", + filePath: "/path/to/foo.js", messages: [{ message: "Unexpected foo.", severity: 2, @@ -44,14 +44,14 @@ describe("formatter:junit", () => { it("should return a single with a message and the line and col number in the body (error)", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); it("should return a single with a message and the line and col number in the body (warning)", () => { code[0].messages[0].severity = 1; const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); @@ -70,7 +70,7 @@ describe("formatter:junit", () => { it("should return a single and an ", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); @@ -86,7 +86,7 @@ describe("formatter:junit", () => { it("should return a single and an ", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); @@ -101,7 +101,7 @@ describe("formatter:junit", () => { it("should return a single and an ", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); @@ -126,7 +126,7 @@ describe("formatter:junit", () => { it("should return a multiple 's", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); @@ -145,7 +145,7 @@ describe("formatter:junit", () => { it("should make them go away", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); @@ -173,7 +173,7 @@ describe("formatter:junit", () => { it("should return 2 's", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); @@ -195,7 +195,7 @@ describe("formatter:junit", () => { it("should return 2 ", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); @@ -208,7 +208,7 @@ describe("formatter:junit", () => { it("should print a passing ", () => { const result = formatter(code); - assert.strictEqual(result.replace(/\n/gu, ""), ""); + assert.strictEqual(result.replace(/\n/gu, ""), ""); }); }); });