Skip to content

Commit fe48720

Browse files
fix: remove logs, update parsing
1 parent 25a2fec commit fe48720

7 files changed

+139
-24
lines changed

cy-example/combined-results.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<testsuites>
3-
<testsuite name="First Test Suite" timestamp="2024-11-20T05:26:28" tests="2" failures="1" time="3.238" file="cy-example/e2e/first.cy.js">
3+
<testsuite name="Second Test Suite" timestamp="2024-11-20T15:19:44" tests="2" failures="0" time="5.351" file="cy-example/e2e/second.cy.js">
4+
<testcase name="Second Test Suite visits google" time="1.349" classname="visits google" failure="false" error="false" success="true"/>
5+
<testcase name="Second Test Suite can search" time="4.002" classname="can search" failure="false" error="false" success="true"/>
6+
</testsuite>
7+
<testsuite name="First Test Suite" timestamp="2024-11-20T15:19:29" tests="2" failures="1" time="4.588" file="cy-example/e2e/first.cy.js">
48
<testcase name="First Test Suite visits google" time="0" classname="visits google" failure="true" error="true" success="false">
59
<failure message="Timed out retrying after 4000ms: expected 'Google' to include 'Amazon'" type="AssertionError">AssertionError: Timed out retrying after 4000ms: expected 'Google' to include 'Amazon'
610
at Context.eval (webpack:///./e2e/first.cy.js:4:15)</failure>
711
</testcase>
8-
<testcase name="First Test Suite can search" time="3.238" classname="can search" failure="false" error="false" success="true"/>
9-
</testsuite>
10-
<testsuite name="Second Test Suite" timestamp="2024-11-20T05:26:40" tests="2" failures="0" time="4.33" file="cy-example/e2e/second.cy.js">
11-
<testcase name="Second Test Suite visits google" time="1.174" classname="visits google" failure="false" error="false" success="true"/>
12-
<testcase name="Second Test Suite can search" time="3.156" classname="can search" failure="false" error="false" success="true"/>
12+
<testcase name="First Test Suite can search" time="4.588" classname="can search" failure="false" error="false" success="true"/>
1313
</testsuite>
1414
</testsuites>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites name="Mocha Tests" time="4.915" tests="2" failures="0">
3+
<testsuite name="Root Suite" timestamp="2024-11-20T16:54:33" tests="0" file="cy-example/e2e/second.cy.js" failures="0" time="0">
4+
</testsuite>
5+
<testsuite name="Second Test Suite" timestamp="2024-11-20T16:54:33" tests="2" failures="0" time="4.915">
6+
<testcase name="Second Test Suite visits google" time="1.184" classname="visits google" failure="false" error="false" success="true">
7+
</testcase>
8+
<testcase name="Second Test Suite can search" time="3.731" classname="can search" failure="false" error="false" success="true">
9+
</testcase>
10+
</testsuite>
11+
</testsuites>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites name="Mocha Tests" time="4.234" tests="2" failures="1">
3+
<testsuite name="Root Suite" timestamp="2024-11-20T16:54:20" tests="0" file="cy-example/e2e/first.cy.js" failures="0" time="0">
4+
</testsuite>
5+
<testsuite name="First Test Suite" timestamp="2024-11-20T16:54:20" tests="2" failures="1" time="4.234">
6+
<testcase name="First Test Suite visits google" time="0" classname="visits google" failure="true" error="true" success="false">
7+
<failure message="Timed out retrying after 4000ms: expected &apos;Google&apos; to include &apos;Amazon&apos;" type="AssertionError"><![CDATA[AssertionError: Timed out retrying after 4000ms: expected 'Google' to include 'Amazon'
8+
at Context.eval (webpack:///./e2e/first.cy.js:4:15)]]></failure>
9+
</testcase>
10+
<testcase name="First Test Suite can search" time="4.234" classname="can search" failure="false" error="false" success="true">
11+
</testcase>
12+
</testsuite>
13+
</testsuites>

scripts/junitXmlToInstanceJson.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fs.readFile(xmlFilePath, "utf-8", (err, data) => {
8484

8585
const suiteJson = {
8686
groupId: result.testsuites.name,
87-
spec: suite.file ?? suite.name,
87+
spec: suite.name,
8888
worker: {
8989
workerIndex: 1,
9090
parallelIndex: 1,
@@ -104,9 +104,7 @@ fs.readFile(xmlFilePath, "utf-8", (err, data) => {
104104
wallClockDuration: durationMillis,
105105
},
106106
tests: testcases.map((test) => {
107-
console.log("FAIL::", test.failure);
108107
const hasFailure = test?.failure && test?.failure !== "false";
109-
console.log("FAILURERES::", extractFailure(test?.failure));
110108
return {
111109
_t: Date.now(),
112110
testId: generateTestId(test?.name, suite.name),
@@ -131,20 +129,24 @@ fs.readFile(xmlFilePath, "utf-8", (err, data) => {
131129
steps: [],
132130
duration: secondsToMilliseconds(parseFloat(test?.time)),
133131
status: hasFailure ? "failed" : "passed",
134-
stdout: test?.["system-out"] ? [test?.["system-out"]] : [],
135-
stderr: hasFailure ? extractFailure(test?.failure) : [],
132+
stdout: test?.["system-out"]
133+
? [test?.["system-out"]]
134+
: undefined,
135+
stderr: hasFailure
136+
? extractFailure(test?.failure)
137+
: undefined,
136138
errors: hasFailure
137139
? [
138140
mergeFailuresIntoMessage(
139141
extractFailure(test?.failure)
140142
) ?? {},
141143
]
142-
: [],
144+
: undefined,
143145
error: hasFailure
144146
? mergeFailuresIntoMessage(
145147
extractFailure(test?.failure)
146148
) ?? {}
147-
: {},
149+
: undefined,
148150
},
149151
],
150152
};
@@ -176,15 +178,13 @@ function extractFailure(failure) {
176178
failureArray.push(failure?._);
177179
}
178180
if (Array.isArray(failure)) {
179-
console.log("ENTER::");
180181
let failureItem;
181182
for (let i = 0; i < failure.length; i++) {
182183
if (typeof failure[i] === "object" && failure[i] !== null) {
183184
failureItem = failure[i];
184185
break;
185186
}
186187
}
187-
console.log("FAIL ITEM::", failureItem);
188188
return extractFailure(failureItem);
189189
}
190190
return failureArray;
@@ -203,5 +203,5 @@ function mergeFailuresIntoMessage(failuresArray) {
203203
}
204204

205205
function secondsToMilliseconds(seconds) {
206-
return Math.round(seconds * 1000);
206+
return seconds * 1000;
207207
}

vitest-example/junit.xml

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<testsuites name="vitest tests" tests="6" failures="2" errors="0" time="0.386">
3-
<testsuite name="vitest-example/tests/stringUtils.spec.js" timestamp="2024-11-20T03:32:00.126Z" hostname="Miguels-Laptop.local" tests="6" failures="2" errors="0" skipped="0" time="0.0079045">
4-
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; capitalizes first letter of each word" time="0.0011366253">
2+
<testsuites name="vitest tests" tests="12" failures="2" errors="0" time="0.397">
3+
<testsuite name="vitest-example/tests/numberUtils.spec.js" timestamp="2024-11-20T15:40:20.746Z" hostname="Miguels-Laptop.local" tests="6" failures="0" errors="0" skipped="0" time="0.0022709579">
4+
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; calculates average of positive numbers" time="0.0009692917">
55
</testcase>
6-
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles already capitalized words" time="0.0001980419">
6+
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; handles array with single number" time="0.0001641254">
77
</testcase>
8-
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles empty string" time="0.0000864573">
8+
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; handles empty array" time="0.00012675">
99
</testcase>
10-
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles single word" time="0.0000859175">
10+
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; handles negative numbers" time="0.0000724592">
1111
</testcase>
12-
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles mixed case input" time="0.00472225">
12+
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; handles decimal numbers" time="0.000227417">
13+
</testcase>
14+
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; returns 0 for invalid input" time="0.0000796661">
15+
</testcase>
16+
</testsuite>
17+
<testsuite name="vitest-example/tests/stringUtils.spec.js" timestamp="2024-11-20T15:40:20.748Z" hostname="Miguels-Laptop.local" tests="6" failures="2" errors="0" skipped="0" time="0.005828125">
18+
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; capitalizes first letter of each word" time="0.0008376656">
19+
</testcase>
20+
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles already capitalized words" time="0.000222208">
21+
</testcase>
22+
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles empty string" time="0.000078042">
23+
</testcase>
24+
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles single word" time="0.0000717506">
25+
</testcase>
26+
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles mixed case input" time="0.0034179993">
1327
<failure message="expected &apos;Hello World&apos; to be &apos;Hello World!&apos; // Object.is equality" type="AssertionError">
1428
AssertionError: expected &apos;Hello World&apos; to be &apos;Hello World!&apos; // Object.is equality
1529

@@ -19,7 +33,7 @@ Received: &quot;Hello World&quot;
1933
❯ vitest-example/tests/stringUtils.spec.js:22:44
2034
</failure>
2135
</testcase>
22-
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; errors on number received" time="0.0006915846">
36+
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; errors on number received" time="0.0005700846">
2337
<failure message="str.split is not a function" type="TypeError">
2438
TypeError: str.split is not a function
2539
❯ Module.capitalizeWords vitest-example/stringUtils.js:4:6
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites tests="1" failures="1" errors="0" skipped="0">
3+
<testsuite name="My Login application incorrect" timestamp="2024-11-20T11:55:55" time="5.25" tests="1" failures="1" errors="0" skipped="0">
4+
<properties>
5+
<property name="specId" value="0"/>
6+
<property name="suiteName" value="My Login application incorrect"/>
7+
<property name="capabilities" value="chrome.131_0_6778_85.mac"/>
8+
<property name="file" value="file://./wdio-example/tests/signup.e2e.js"/>
9+
</properties>
10+
<testcase classname="chrome.131_0_6778_85.mac.My_Login_application_incorrect" name="should not login with invalid credentials" time="5.248" file="file://./wdio-example/tests/signup.e2e.js">
11+
<failure message="Expect to have text&#xA;&#xA;Expected: StringContaining &quot;You logged into a secure area!&quot;&#xA;Received: &quot;Your password is invalid!&#xA;×&quot;"/>
12+
<system-out><![CDATA[
13+
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.4/clear - {}
14+
RESULT: {}
15+
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.4/value - {"text":"tomsmith"}
16+
RESULT: {"text":"tomsmith"}
17+
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.6/clear - {}
18+
RESULT: {}
19+
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.6/value - {"text":"123"}
20+
RESULT: {"text":"123"}
21+
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.7/click - {}
22+
RESULT: {}
23+
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
24+
RESULT: {}
25+
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
26+
RESULT: {}
27+
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
28+
RESULT: {}
29+
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
30+
RESULT: {}
31+
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
32+
RESULT: {}
33+
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
34+
RESULT: {}
35+
COMMAND: DELETE /session/d508f942d7ce0715a049272f75f5c966 - {}
36+
RESULT: {}
37+
]]></system-out>
38+
<system-err><![CDATA[
39+
Error: Expect to have text
40+
41+
Expected: StringContaining "You logged into a secure area!"
42+
Received: "Your password is invalid!
43+
×"
44+
at Context.<anonymous> (/Users/miguelangarano/Documents/GitHub/generic-api-example/wdio-example/tests/signup.e2e.js:11:41)
45+
]]></system-err>
46+
</testcase>
47+
</testsuite>
48+
</testsuites>
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites tests="1" failures="0" errors="0" skipped="0">
3+
<testsuite name="My Login application" timestamp="2024-11-20T11:55:55" time="2.43" tests="1" failures="0" errors="0" skipped="0">
4+
<properties>
5+
<property name="specId" value="0"/>
6+
<property name="suiteName" value="My Login application"/>
7+
<property name="capabilities" value="chrome.131_0_6778_85.mac"/>
8+
<property name="file" value="file://./wdio-example/tests/test.e2e.js"/>
9+
</properties>
10+
<testcase classname="chrome.131_0_6778_85.mac.My_Login_application" name="should login with valid credentials" time="2.429" file="file://./wdio-example/tests/test.e2e.js">
11+
<system-out><![CDATA[
12+
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.4/clear - {}
13+
RESULT: {}
14+
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.4/value - {"text":"tomsmith"}
15+
RESULT: {"text":"tomsmith"}
16+
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.6/clear - {}
17+
RESULT: {}
18+
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.6/value - {"text":"SuperSecretPassword!"}
19+
RESULT: {"text":"SuperSecretPassword!"}
20+
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.7/click - {}
21+
RESULT: {}
22+
COMMAND: GET /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.752C3C14B55001F6F7728C476DC27EEE.e.15/text - {}
23+
RESULT: {}
24+
COMMAND: DELETE /session/69b60adbc65a7e265fc3972621eec652 - {}
25+
RESULT: {}
26+
]]></system-out>
27+
</testcase>
28+
</testsuite>
29+
</testsuites>

0 commit comments

Comments
 (0)