diff --git a/__tests__/__outputs__/jest-react-component-test-results.md b/__tests__/__outputs__/jest-react-component-test-results.md
new file mode 100644
index 00000000..7891a19b
--- /dev/null
+++ b/__tests__/__outputs__/jest-react-component-test-results.md
@@ -0,0 +1,10 @@
+![Tests passed successfully](https://img.shields.io/badge/tests-1%20passed-success)
+## ✅ fixtures/external/jest/jest-react-component-test-results.xml
+**1** tests were completed in **1000ms** with **1** passed, **0** failed and **0** skipped.
+|Test suite|Passed|Failed|Skipped|Time|
+|:---|---:|---:|---:|---:|
+|[\](#r0s0)|1✅|||798ms|
+### ✅ \
+```
+✅ should render properly
+```
\ No newline at end of file
diff --git a/__tests__/__snapshots__/jest-junit.test.ts.snap b/__tests__/__snapshots__/jest-junit.test.ts.snap
index fe61966f..f29b5c82 100644
--- a/__tests__/__snapshots__/jest-junit.test.ts.snap
+++ b/__tests__/__snapshots__/jest-junit.test.ts.snap
@@ -1,5 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`jest-junit tests report from #235 testing react components named 1`] = `
+TestRunResult {
+ "path": "fixtures/external/jest/jest-react-component-test-results.xml",
+ "suites": [
+ TestSuiteResult {
+ "groups": [
+ TestGroupResult {
+ "name": "",
+ "tests": [
+ TestCaseResult {
+ "error": undefined,
+ "name": " should render properly",
+ "result": "success",
+ "time": 704,
+ },
+ ],
+ },
+ ],
+ "name": "\\",
+ "totalTime": 798,
+ },
+ ],
+ "totalTime": 1000,
+}
+`;
+
exports[`jest-junit tests report from ./reports/jest test results matches snapshot 1`] = `
TestRunResult {
"path": "fixtures/jest-junit.xml",
diff --git a/__tests__/fixtures/external/jest/jest-react-component-test-results.xml b/__tests__/fixtures/external/jest/jest-react-component-test-results.xml
new file mode 100644
index 00000000..cdaa87f1
--- /dev/null
+++ b/__tests__/fixtures/external/jest/jest-react-component-test-results.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/__tests__/jest-junit.test.ts b/__tests__/jest-junit.test.ts
index b6533e62..d42405cf 100644
--- a/__tests__/jest-junit.test.ts
+++ b/__tests__/jest-junit.test.ts
@@ -82,4 +82,27 @@ describe('jest-junit tests', () => {
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
+
+ it('report from #235 testing react components named ', async () => {
+ const fixturePath = path.join(__dirname, 'fixtures', 'external', 'jest', 'jest-react-component-test-results.xml')
+ const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'jest', 'files.txt')
+ const outputPath = path.join(__dirname, '__outputs__', 'jest-react-component-test-results.md')
+ const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
+ const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
+
+ const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
+ const opts: ParseOptions = {
+ parseErrors: true,
+ trackedFiles
+ //workDir: '/home/dorny/dorny/jest/'
+ }
+
+ const parser = new JestJunitParser(opts)
+ const result = await parser.parse(filePath, fileContent)
+ expect(result).toMatchSnapshot()
+
+ const report = getReport([result])
+ fs.mkdirSync(path.dirname(outputPath), {recursive: true})
+ fs.writeFileSync(outputPath, report)
+ })
})
diff --git a/dist/index.js b/dist/index.js
index 44bf97d2..24d846e1 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1212,7 +1212,7 @@ class JestJunitParser {
const suites = junit.testsuites.testsuite === undefined
? []
: junit.testsuites.testsuite.map(ts => {
- const name = ts.$.name.trim();
+ const name = this.escapeCharacters(ts.$.name.trim());
const time = parseFloat(ts.$.time) * 1000;
const sr = new test_results_1.TestSuiteResult(name, this.getGroups(ts), time);
return sr;
@@ -1281,6 +1281,9 @@ class JestJunitParser {
var _a, _b;
return ((_b = (_a = this.options.workDir) !== null && _a !== void 0 ? _a : this.assumedWorkDir) !== null && _b !== void 0 ? _b : (this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles)));
}
+ escapeCharacters(s) {
+ return s.replace(/([<>])/g, '\\$1');
+ }
}
exports.JestJunitParser = JestJunitParser;