Navigation Menu

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

Closed
6 tasks done
flunderpero opened this issue Aug 8, 2022 · 1 comment · Fixed by #1890
Closed
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
Labels

Comments

@flunderpero
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; // Object.is equality" type="AssertionError">
AssertionError: expected '' to be 'English Title' // Object.is equality
 ❯ test_function packages/server.faas.scrape/__tests__/scrape_basics.spec.ts:26:30
 ❯ Server.<anonymous> packages/lib.shared.test/fixtures.ts:16:16
            </failure>
        </testcase>

The string <anonymous> should be escaped.

Reproduction

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

https://stackblitz.com/edit/vitest-dev-vitest-b4w9ta?file=test/basic.test.ts

System Info

System:
    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
  Binaries:
    Node: 18.7.0 - /usr/bin/node
    Yarn: 3.1.0 - /usr/bin/yarn
    npm: 8.15.0 - /usr/bin/npm
  npmPackages:
    vitest: 0.21.0 => 0.21.0

Used Package Manager

yarn

Validations

@flunderpero
Copy link
Author

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.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants