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

fix: remove invalid xml characters in junit reporter output (fix #1144) #1145

Merged
merged 2 commits into from Apr 14, 2022

Conversation

ciddan
Copy link
Contributor

@ciddan ciddan commented Apr 12, 2022

This line in data.ts contains two control characters, visible in vs code:

Screenshot from 2022-04-12 22-41-50

That line is scrubbed by the new removeInvalidXMLCharacters function, ensuring that the XML output doesn't contain the control characters.

Reproduction

Reproduction StackBlitz.

Let the tests run and open test_result/junit.xml. The file contains disallowed characters, specifically in the tag.

You can use any XML validator to check, such as the one from w3schools.

@netlify
Copy link

netlify bot commented Apr 12, 2022

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit e4d9dec
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/6255e5d6ad3c4c0008c499ab
😎 Deploy Preview https://deploy-preview-1145--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@antfu antfu merged commit ab8e2b8 into vitest-dev:main Apr 14, 2022
chaii3 pushed a commit to chaii3/vitest that referenced this pull request May 13, 2022
@dheardal
Copy link

dheardal commented Jul 5, 2022

I'm still seeing issues with this from the output of a react test:

Screenshot 2022-07-05 at 11 21 53

Vitest version 0.17.0

@kaliatech
Copy link

I'm seeing similar with vitest 0.18.0. It looks as if the encoding and escaping stop at some point when processing a large failure message.

Here is a copy paste with large sections removed. It shows correct encoding/escaping at first, but then seems to stop until getting to the next test case.

<testcase classname="src/components/team-view/TeamView.test.tsx" name="Test the TeamView component &gt; Should render successfully" time="0.0180000000">
            <failure message="Found multiple elements by: [data-testid=&quot;row-a1&quot;]

Here are the matching elements:

Ignored nodes: comments, &lt;script /&gt;, &lt;style /&gt;
[36m&lt;div[39m
  [33mdata-e2etestid[39m=[32m&quot;row-a1&quot;[39m

......LOTS OF VALID ENCODING......

                [36m/&gt;[39m
                [36m&lt;path[39m
                  [33mclip-rule[39m=[32m&quot;evenodd&quot;[39m
                  [33md[39m=[32m&quot;M206.012 384.08C208.492 383.134 210.972..." type="TestingLibraryElementError">
TestingLibraryElementError: Found multiple elements by: [data-testid="row-a1"]

Here are the matching elements:

Ignored nodes: comments, <script />, <style />
[36m<div[39m
  [33mdata-e2etestid[39m=[32m"row-a1"[39m
  [33mdata-testid[39m=[32m"row-a1"[39m

.....NOTE HOW IT SUDDENY STOPPED ENCODING IN PREVIOUS SECTION (AND ALSO HIDDEN INVALID CHARS)....

.....LOTS OF MISSING ENCODING AND INVALID CHARACTERS...

                  �[33mclip-rule�[39m=�[32m"evenodd"�[39m
                  �[33md�[39m=�[32m"M206.012 384.08C208.492 383.134 ...
 ❯ Object.getElementError ../node_modules/@testing-library/dom/dist/config.js:40:19
 ❯ getElementError ../node_modules/@testing-library/dom/dist/query-helpers.js:25:35
 ❯ getMultipleElementsFoundError ../node_modules/@testing-library/dom/dist/query-helpers.js:29:10
 ❯ ../node_modules/@testing-library/dom/dist/query-helpers.js:66:13
 ❯ ../node_modules/@testing-library/dom/dist/query-helpers.js:111:19
 ❯ src/components/team-view/TeamView.test.tsx:34:34
            </failure>
        </testcase>

.....BUT THEN WHEN IT ENDS AND GOES TO NEXT TEST CASE, EVERYTHING IS GOOD AGAIN...

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

Successfully merging this pull request may close these issues.

None yet

5 participants