diff --git a/package.json b/package.json index efe14a4..7d40a00 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "author": "Vojta Jina ", "dependencies": { "path-is-absolute": "^1.0.0", - "xmlbuilder": "8.2.2" + "xmlbuilder": "12.0.0" }, "peerDependencies": { "karma": ">=0.9" diff --git a/test/reporter.spec.js b/test/reporter.spec.js index b8925ac..7d6772c 100644 --- a/test/reporter.spec.js +++ b/test/reporter.spec.js @@ -22,6 +22,8 @@ var fakeHelper = { mkdirIfNotExists: sinon.stub().yields() } +var fakeFormatError = sinon.spy(function (v) { return v }) + var fakeConfig = { basePath: __dirname, junitReporter: { @@ -52,7 +54,7 @@ describe('JUnit reporter', function () { }) beforeEach(function () { - reporter = new reporterModule['reporter:junit'][1](fakeBaseReporterDecorator, fakeConfig, fakeLogger, fakeHelper) + reporter = new reporterModule['reporter:junit'][1](fakeBaseReporterDecorator, fakeConfig, fakeLogger, fakeHelper, fakeFormatError) }) it('should produce valid XML per the new SonarQube reporting format', function () { @@ -165,6 +167,41 @@ describe('JUnit reporter', function () { expect(writtenXml).to.have.string('testcase name="Sender using it get request should not fail"') }) + it('should safely handle special characters', function () { + var fakeBrowser = { + id: 'Android_4_1_2', + name: 'Android', + fullName: 'Android 4.1.2', + lastResult: { + error: false, + total: 1, + failed: 1, + netTime: 10 * 1000 + } + } + + var fakeResult = { + suite: [ + 'Sender', + 'using it', + 'get request' + ], + success: false, + description: 'should not fail', + log: ['Expected "👍" to be "👎".'] + } + + reporter.onRunStart([ fakeBrowser ]) + reporter.specSuccess(fakeBrowser, fakeResult) + reporter.onBrowserComplete(fakeBrowser) + reporter.onRunComplete() + + expect(fakeFs.writeFile).to.have.been.called + + var writtenXml = fakeFs.writeFile.firstCall.args[1] + expect(writtenXml).to.have.string('Expected "👍" to be "👎".') + }) + it('should safely handle missing suite browser entries when specSuccess fires', function () { reporter.onRunStart([]) // don't try to call null.ele()