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

Invalid XML produced if an error message contains an ESC character (0x1B) #197

Closed
asztal opened this issue Jan 25, 2022 · 2 comments
Closed

Comments

@asztal
Copy link

asztal commented Jan 25, 2022

To reproduce the issue:

test("breaks jest-junit", () => {
    throw new Error("\x1b");
});

For example, this can be produced by the @testing-library/react when it decides the summary of the DOM is too long and truncates it (as it may happen to truncate the text in the middle of an ANSI escape code, meaning strip-ansi won't remove it).

The output is:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="1" failures="1" errors="0" time="2">
  <testsuite name="undefined" errors="0" failures="1" skipped="0" timestamp="2022-01-25T12:11:51" time="1.561" tests="1">
    <testcase classname=" breaks jest-junit" name=" breaks jest-junit" time="0.001">
      <failure>Error: �
    at Object.&lt;anonymous&gt; (/home/lee/project/src/junit.spec.ts:2:11)
    at Object.asyncJestTest (/home/lee/project/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)
    at /home/lee/project/node_modules/jest-jasmine2/build/queueRunner.js:45:12
    at new Promise (&lt;anonymous&gt;)
    at mapper (/home/lee/project/node_modules/jest-jasmine2/build/queueRunner.js:28:19)
    at /home/lee/project/node_modules/jest-jasmine2/build/queueRunner.js:75:41
    at processTicksAndRejections (node:internal/process/task_queues:96:5)</failure>
    </testcase>
  </testsuite>
</testsuites>

This is invalid XML and makes it harder to see why the test failed since Azure DevOps rejects the junit.xml file.

@palmerj3
Copy link
Collaborator

Thank you!

Could you please create a repo that reproduces this issue? Then i'd be happy to have a look.

@cc-ebay
Copy link

cc-ebay commented Jan 31, 2022

It is pretty straightforward how to reproduce it. The output in the XML should filter out an ESC characters sequences

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

No branches or pull requests

3 participants