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

ANSI escape codes in messages break xunit file #2955

Closed
jkrems opened this issue Aug 12, 2017 · 0 comments
Closed

ANSI escape codes in messages break xunit file #2955

jkrems opened this issue Aug 12, 2017 · 0 comments

Comments

@jkrems
Copy link

jkrems commented Aug 12, 2017

When the error message or stack contains any non-safe characters, it breaks the xunit file and the resulting report is no longer valid XML.

Repro:

# Explicit:
npm init --yes
npm i -D mocha
echo "it('throws', () => { throw new Error('\x1B[32mfoo\x1B[0m'); })">test.js
./node_modules/.bin/mocha -R xunit -O output=report.xml test.js

# One-liner:
npm init --yes >/dev/null && npm i -D mocha >/dev/null && echo "it('throws', () => { throw new Error('\x1B[32mfoo\x1B[0m'); })">test.js && ./node_modules/.bin/mocha -R xunit -O output=report.xml test.js

Running report.xml through an online validator will trigger messages like the following:

An invalid XML character (Unicode: 0x1b) was found in the element content of the document.

jkrems pushed a commit to jkrems/mocha that referenced this issue Aug 13, 2017
boneskull pushed a commit that referenced this issue Sep 3, 2017
sgilroy pushed a commit to TwineHealth/mocha that referenced this issue Feb 27, 2019
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

1 participant