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

Test suite name is disappear from table when name containing < and > #235

Closed
wingyplus opened this issue Mar 13, 2023 · 2 comments · Fixed by #236 or wingyplus/test-reporter#3
Assignees
Labels
bug Something isn't working
Milestone

Comments

@wingyplus
Copy link
Contributor

wingyplus commented Mar 13, 2023

I use this action to generate test report. My team has a convention that testing React component will be named as <ComponentName />. When the report generated the suite name is empty in the table:

Screenshot 2566-03-13 at 12 09 48

So I start reproduce in this repository by adding these steps:

Apply this patch to this repository:

$ git diff __tests__/fixtures/external/jest/jest-test-results.xml 
diff --git a/__tests__/fixtures/external/jest/jest-test-results.xml b/__tests__/fixtures/external/jest/jest-test-results.xml
index f35d4a5..b52ac46 100644
--- a/__tests__/fixtures/external/jest/jest-test-results.xml
+++ b/__tests__/fixtures/external/jest/jest-test-results.xml
@@ -9354,4 +9354,8 @@ Received string:  &quot;·
     <testcase classname="" name="errors when a test both returns a promise and takes a callback" time="0.704">
     </testcase>
   </testsuite>
-</testsuites>
\ No newline at end of file
+  <testsuite name="&lt;Component /&gt;" errors="0" failures="0" skipped="0" timestamp="2021-01-24T19:21:45" time="0.798" tests="118">
+    <testcase classname="" name="&lt;Component /&gt; should render properly" time="0.704">
+    </testcase>
+  </testsuite>
+</testsuites>

After that, run npm run test and see the output in __outputs__ directory:

diff --git a/__tests__/__outputs__/jest-test-results.md b/__tests__/__outputs__/jest-test-results.md
index bc86f3c..77edc01 100644
--- a/__tests__/__outputs__/jest-test-results.md
+++ b/__tests__/__outputs__/jest-test-results.md
@@ -1,8 +1,9 @@
-![Tests failed](https://img.shields.io/badge/tests-4207%20passed%2C%202%20failed%2C%2030%20skipped-critical)
+![Tests failed](https://img.shields.io/badge/tests-4208%20passed%2C%202%20failed%2C%2030%20skipped-critical)
 ## ❌ <a id="user-content-r0" href="#r0">fixtures/external/jest/jest-test-results.xml</a>
-**4239** tests were completed in **166s** with **4207** passed, **2** failed and **30** skipped.
+**4240** tests were completed in **166s** with **4208** passed, **2** failed and **30** skipped.
 |Test suite|Passed|Failed|Skipped|Time|
 |:---|---:|---:|---:|---:|
+|<Component />|1✅|||798ms|
 |e2e/__tests__/asyncAndCallback.test.ts|1✅|||746ms|
 |e2e/__tests__/asyncRegenerator.test.ts|1✅|||4s|
 |e2e/__tests__/autoClearMocks.test.ts|2✅|||2s|
@@ -78,7 +79,7 @@
 |e2e/__tests__/jasmineAsyncWithPendingDuringTest.ts|1✅||1⚪|72ms|
 |e2e/__tests__/jest.config.js.test.ts|3✅|||2s|
 |e2e/__tests__/jest.config.ts.test.ts|5✅|||14s|
-|[e2e/__tests__/jestChangedFiles.test.ts](#r0s75)|9✅|1❌||9s|
+|[e2e/__tests__/jestChangedFiles.test.ts](#r0s76)|9✅|1❌||9s|
 |e2e/__tests__/jestEnvironmentJsdom.test.ts|1✅|||2s|
 |e2e/__tests__/jestRequireActual.test.ts|1✅|||2s|
 |e2e/__tests__/jestRequireMock.test.ts|1✅|||2s|
@@ -101,7 +102,7 @@
 |e2e/__tests__/nodePath.test.ts|1✅|||866ms|
 |e2e/__tests__/noTestFound.test.ts|2✅|||1s|
 |e2e/__tests__/noTestsFound.test.ts|5✅|||3s|
-|[e2e/__tests__/onlyChanged.test.ts](#r0s98)|8✅|1❌||22s|
+|[e2e/__tests__/onlyChanged.test.ts](#r0s99)|8✅|1❌||22s|
 |e2e/__tests__/onlyFailuresNonWatch.test.ts|1✅|||3s|
 |e2e/__tests__/overrideGlobals.test.ts|2✅|||2s|
 |e2e/__tests__/pnp.test.ts|1✅|||3s|
@@ -403,7 +404,7 @@
 |packages/pretty-format/src/__tests__/prettyFormat.test.ts|86✅|||219ms|
 |packages/pretty-format/src/__tests__/react.test.tsx|55✅|||325ms|
 |packages/pretty-format/src/__tests__/ReactElement.test.ts|3✅|||64ms|
-### ❌ <a id="user-content-r0s75" href="#r0s75">e2e/__tests__/jestChangedFiles.test.ts</a>
+### ❌ <a id="user-content-r0s76" href="#r0s76">e2e/__tests__/jestChangedFiles.test.ts</a>
 \`\`\`
 ✅ gets hg SCM roots and dedupes them
 ✅ gets git SCM roots and dedupes them
@@ -417,7 +418,7 @@
 ✅ monitors only root paths for hg
 ✅ handles a bad revision for "changedSince", for hg
 \`\`\`
-### ❌ <a id="user-content-r0s98" href="#r0s98">e2e/__tests__/onlyChanged.test.ts</a>
+### ❌ <a id="user-content-r0s99" href="#r0s99">e2e/__tests__/onlyChanged.test.ts</a>
 \`\`\`
 ✅ run for "onlyChanged" and "changedSince"
 ✅ run only changed files

You may see that the suite name <Component /> render without escape but in Markdown Preview it shows empty as per screenshot belows:

Screenshot 2566-03-13 at 12 09 02

NOTE: I use VSCode markdown preview feature to rendering the markdown file.

So I try modifying the output markdown file to \<Component /\>. The suite name is now show in the rendered markdown preview.

This found in both java-junit and jest-junit format.

wingyplus added a commit to wingyplus/test-reporter that referenced this issue Mar 13, 2023
@wingyplus
Copy link
Contributor Author

I open PR to solve the issue. If the maintainer think it's the right to fix. I'll continue fixing the test. 🙇

wingyplus added a commit to wingyplus/test-reporter that referenced this issue Mar 13, 2023
wingyplus added a commit to wingyplus/test-reporter that referenced this issue Mar 13, 2023
@wingyplus wingyplus reopened this Mar 13, 2023
@j-catania j-catania added the bug Something isn't working label Sep 22, 2023
@jozefizso jozefizso self-assigned this Dec 18, 2023
@jozefizso
Copy link
Collaborator

Thanks for the contribution @wingyplus! This is very useful for React and Vue developers!

jozefizso pushed a commit to wingyplus/test-reporter that referenced this issue Dec 18, 2023
jozefizso pushed a commit to wingyplus/test-reporter that referenced this issue Dec 18, 2023
jozefizso pushed a commit to wingyplus/test-reporter that referenced this issue Dec 18, 2023
@jozefizso jozefizso added this to the v1.8.0 milestone Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants