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

Junit reporter does not escape error messages and stacktraces #1823

6 tasks done
flunderpero opened this issue Aug 8, 2022 · 1 comment · Fixed by #1890
6 tasks done

Junit reporter does not escape error messages and stacktraces #1823

flunderpero opened this issue Aug 8, 2022 · 1 comment · Fixed by #1890


Copy link

Describe the bug

The Junit reporter produces illegal XML if something resembling an XML tag shows up in the error message or stack trace.

As an example, we get this Junit-XML which is clearly malformed:

<testcase classname="packages/server.faas.scrape/__tests__/scrape_basics.spec.ts" name="Extract title from title tag" time="3.3660000000">
            <failure message="expected &apos;&apos; to be &apos;English Title&apos; // equality" type="AssertionError">
AssertionError: expected '' to be 'English Title' // equality
 ❯ test_function packages/server.faas.scrape/__tests__/scrape_basics.spec.ts:26:30
 ❯ Server.<anonymous> packages/lib.shared.test/fixtures.ts:16:16

The string <anonymous> should be escaped.


See the following Stackblitz for an example of a test that produces malformed XML:

System Info

    OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Xeon(R) CPU @ 2.20GHz
    Memory: 2.61 GB / 3.84 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
    Node: 18.7.0 - /usr/bin/node
    Yarn: 3.1.0 - /usr/bin/yarn
    npm: 8.15.0 - /usr/bin/npm
    vitest: 0.21.0 => 0.21.0

Used Package Manager



Copy link

I am trying to create a PR but I cannot get the reporters test suite to run. Running vitest run test/reporters gives
No test suite found in file test/reporters/tests/reporters.spec.ts

Am I missing something? And another question: Would it be ok / desirable if I modified test/reporters/src/data.ts to include an error with invalid XML syntax or should I build up my own files in the test case I am writing? I am fine with both.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging a pull request may close this issue.

2 participants