Skip to content

Commit 04d3928

Browse files
committed
fixing error
1 parent b072edf commit 04d3928

16 files changed

+3034
-1634
lines changed

data/lots-of-results.xml

Lines changed: 2181 additions & 0 deletions
Large diffs are not rendered by default.

data/xunit-2-2.xml

Lines changed: 384 additions & 0 deletions
Large diffs are not rendered by default.

data/xunit-2.xml

Lines changed: 384 additions & 0 deletions
Large diffs are not rendered by default.

index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

junit.xml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuites name="jest tests" tests="13" failures="0" errors="0" time="5.824">
3-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:14" time="1.603" tests="1">
4-
<testcase classname=" complete multi suites" name=" complete multi suites" time="0.141">
2+
<testsuites name="jest tests" tests="13" failures="0" errors="0" time="6.554">
3+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:34" time="1.902" tests="1">
4+
<testcase classname=" get files" name=" get files" time="0.037">
55
</testcase>
66
</testsuite>
7-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:14" time="1.748" tests="1">
8-
<testcase classname=" renders toggle" name=" renders toggle" time="0.016">
7+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:33" time="2.014" tests="1">
8+
<testcase classname=" get description" name=" get description" time="0.182">
99
</testcase>
1010
</testsuite>
11-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:14" time="1.92" tests="1">
12-
<testcase classname=" get description" name=" get description" time="0.01">
11+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:34" time="2.175" tests="1">
12+
<testcase classname=" complete multi suites" name=" complete multi suites" time="0.018">
1313
</testcase>
1414
</testsuite>
15-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:14" time="1.733" tests="1">
16-
<testcase classname=" renders suite options" name=" renders suite options" time="0.047">
15+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:36" time="0.508" tests="1">
16+
<testcase classname=" renders properties options" name=" renders properties options" time="0.072">
1717
</testcase>
1818
</testsuite>
19-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:14" time="1.858" tests="1">
20-
<testcase classname=" renders suite" name=" renders suite" time="0.151">
19+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:36" time="0.591" tests="1">
20+
<testcase classname=" renders files" name=" renders files" time="0.022">
2121
</testcase>
2222
</testsuite>
23-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:14" time="2.082" tests="1">
24-
<testcase classname=" renders test options" name=" renders test options" time="0.121">
23+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:36" time="0.516" tests="1">
24+
<testcase classname=" renders suite" name=" renders suite" time="0.034">
2525
</testcase>
2626
</testsuite>
27-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:15" time="0.436" tests="1">
28-
<testcase classname=" renders logo" name=" renders logo" time="0.004">
27+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:36" time="0.368" tests="1">
28+
<testcase classname=" renders test options" name=" renders test options" time="0.012">
2929
</testcase>
3030
</testsuite>
31-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:15" time="0.705" tests="1">
32-
<testcase classname=" renders files" name=" renders files" time="0.173">
31+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:36" time="0.329" tests="2">
32+
<testcase classname=" renders hero" name=" renders hero" time="0.005">
3333
</testcase>
34-
</testsuite>
35-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:16" time="0.331" tests="1">
36-
<testcase classname=" get files" name=" get files" time="0.023">
34+
<testcase classname=" renders hero with title and brand" name=" renders hero with title and brand" time="0.002">
3735
</testcase>
3836
</testsuite>
39-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:14" time="2.209" tests="1">
40-
<testcase classname=" get suites" name=" get suites" time="0.547">
37+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:36" time="0.311" tests="1">
38+
<testcase classname=" renders suite options" name=" renders suite options" time="0.005">
4139
</testcase>
4240
</testsuite>
43-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:16" time="0.477" tests="1">
44-
<testcase classname=" renders properties options" name=" renders properties options" time="0.01">
41+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:37" time="0.256" tests="1">
42+
<testcase classname=" renders toggle" name=" renders toggle" time="0.003">
4543
</testcase>
4644
</testsuite>
47-
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T11:56:16" time="0.476" tests="2">
48-
<testcase classname=" renders hero" name=" renders hero" time="0.065">
45+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:37" time="0.271" tests="1">
46+
<testcase classname=" renders logo" name=" renders logo" time="0.003">
4947
</testcase>
50-
<testcase classname=" renders hero with title and brand" name=" renders hero with title and brand" time="0.003">
48+
</testsuite>
49+
<testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-05-20T12:41:34" time="3.5" tests="1">
50+
<testcase classname=" get suites" name=" get suites" time="1.361">
5151
</testcase>
5252
</testsuite>
5353
</testsuites>

src/app/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ const App = ({ files, title, brand }) => {
9898
</header>
9999
<main>
100100
<div className='container'>
101-
{state.error && <Error error={state.error} />}
102-
{state.error === null && Object.values(state.currentSuites).length === 0 && <Loading />}
101+
{state.errors && <Error errors={state.errors} />}
102+
{state.errors === null && Object.values(state.currentSuites).length === 0 && <Loading />}
103103
{Object.values(state.currentSuites).length > 0 && <div>
104104
{
105105
Object.values(state.currentSuites)

src/app/error.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@ import React from 'react'
22

33
const issueUrl = 'https://github.com/lukejpreston/xunit-viewer/issues/new?assignees=&labels=&template=issue.md&title='
44

5-
const Error = ({ error }) => (
5+
const Error = ({ errors }) => {
6+
return (
67
<div className='content mt-5'>
7-
<h2 className='subtitle has-text-danger'>Error</h2>
8+
<h2 className='subtitle has-text-danger'>Errors found</h2>
89
<p>There was an error parsing your data.</p>
9-
<p>{error}</p>
10+
<ul>
11+
{errors.map(({ file, error }) => (
12+
<li key={file}>
13+
<b>{file}</b>
14+
<br />
15+
<p>{error}</p>
16+
</li>
17+
))}
18+
</ul>
1019
<p>
1120
If you think this is an issue with the library please raise it here <a href={issueUrl} target='_blank' rel="noreferrer">GitHub Issue</a>
1221
</p>
1322
</div>
14-
)
23+
)
24+
}
1525

1626
export default Error

src/app/parse-all.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,40 @@ export default async (dispatch, files, suites) => {
55
for (const { file, contents } of files) {
66
try {
77
const parsed = await parse(contents)
8-
suites = merge.recursive(true, suites, parsed)
9-
if (Object.keys(suites.suites).length === 0) {
8+
if (Object.keys(parsed.suites).length === 0) {
109
dispatch({
1110
type: 'parse-error',
1211
payload: {
13-
error: 'No suites or tests detected in this file. It might be in a format not supported yet. Please raise an issue with the data so it can be addressed 😃'
14-
}
15-
})
16-
} else {
17-
dispatch({
18-
type: 'parse-suites',
19-
payload: {
20-
suites: suites.suites
12+
file,
13+
error: 'No suites or tests detected in this file. It could be an unsupported format.'
2114
}
2215
})
2316
}
17+
suites = merge.recursive(true, suites, parsed)
2418
} catch (err) {
25-
console.log('Failed to parse', file, '\n', err.message)
2619
dispatch({
2720
type: 'parse-error',
2821
payload: {
29-
error: err
22+
file,
23+
error: err.message
3024
}
3125
})
3226
}
3327
}
28+
if (Object.keys(suites.suites).length > 0) {
29+
dispatch({
30+
type: 'parse-suites',
31+
payload: {
32+
suites: suites.suites
33+
}
34+
})
35+
} else {
36+
dispatch({
37+
type: 'parse-error',
38+
payload: {
39+
file: 'See errors',
40+
error: 'No suites or tests detected.'
41+
}
42+
})
43+
}
3444
}

src/app/reducer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export default (state, { type, payload }) => {
3434

3535
if (type === 'parse-error') {
3636
state = merge.recursive(true, {}, state)
37-
state.error = payload.error
37+
state.errors = state.errors || []
38+
state.errors.push({
39+
error: payload.error,
40+
file: payload.file
41+
})
3842
return state
3943
}
4044

src/cli/get-files.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const expectedFiles = [
1717
path.resolve(__dirname, '../../data/invalid.xml'),
1818
path.resolve(__dirname, '../../data/issue_2.xml'),
1919
path.resolve(__dirname, '../../data/issue_3.xml'),
20+
path.resolve(__dirname, '../../data/lots-of-results.xml'),
2021
path.resolve(__dirname, '../../data/malformed.xml'),
2122
path.resolve(__dirname, '../../data/most_complex.xml'),
2223
path.resolve(__dirname, '../../data/multi-name-unique-classname.xml'),
@@ -35,7 +36,9 @@ const expectedFiles = [
3536
path.resolve(__dirname, '../../data/suite-system-out.xml'),
3637
path.resolve(__dirname, '../../data/test-system-out.xml'),
3738
path.resolve(__dirname, '../../data/test.xml'),
38-
path.resolve(__dirname, '../../data/with_html.xml')
39+
path.resolve(__dirname, '../../data/with_html.xml'),
40+
path.resolve(__dirname, '../../data/xunit-2-2.xml'),
41+
path.resolve(__dirname, '../../data/xunit-2.xml')
3942
]
4043

4144
test('get files', () => {

0 commit comments

Comments
 (0)