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

mocha escapes the grave character incorrectly in xunit reporter #3002

Closed
4 tasks done
arwilczek90 opened this issue Sep 11, 2017 · 2 comments
Closed
4 tasks done

mocha escapes the grave character incorrectly in xunit reporter #3002

arwilczek90 opened this issue Sep 11, 2017 · 2 comments

Comments

@arwilczek90
Copy link

Prerequisites

  • Checked that your issue isn't already filed by cross referencing issues with the common mistake label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
    node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha.

Description

The mocha xunit reporter escapes the grave character (`) incorrectly in the xunit reporter when placed in the spec name. It escapes it with ` which is valid in html but not in xml causing junit parsers (specifically jenkins in my test case but I have tested it with the w3schools validator as well with the same result) to not be able to parse test results.

Steps to Reproduce

Run the following code in the terminal.

npm init --yes
npm i -D mocha
echo "const assert = require('assert');\nit('this `creates` bad xml', () => {assert.ok(true);});" > test.js
./node_modules/.bin/mocha -R xunit -O output=report.xml test.js

Then take the resulting file and run it through an xml validator or a junit test result parser.

Expected behavior: [What you expect to happen]
produces a valid xml file

<testsuite name="Mocha Tests" tests="1" failures="0" errors="0" skipped="0" timestamp="Mon, 11 Sep 2017 18:19:30 GMT" time="0.004">
<testcase classname="" name="this `creates` bad xml" time="0.001"/>
</testsuite>

Actual behavior: [What actually happens]
Produces an invalid xml file with &grave; instead of the "`" character

<testsuite name="Mocha Tests" tests="1" failures="0" errors="0" skipped="0" timestamp="Mon, 11 Sep 2017 18:19:30 GMT" time="0.004">
<testcase classname="" name="this &grave;creates&grave; bad xml" time="0.001"/>
</testsuite>

Reproduces how often: [What percentage of the time does it reproduce?]
I am able to reproduce this 100% of the time.

Versions

Happens on mocha>=3.5.1
tested on osx 10.12 and ubuntu 14.04 with node 6.11.1, 6.11.2, 6.11.3

Additional Information

@boneskull
Copy link
Contributor

closed by #3003

@arwilczek90
Copy link
Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants