Skip to content

Commit

Permalink
fix: remove logs, update parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Nov 20, 2024
1 parent 25a2fec commit fe48720
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 24 deletions.
12 changes: 6 additions & 6 deletions cy-example/combined-results.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testsuites>
<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">
<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">
<testcase name="Second Test Suite visits google" time="1.349" classname="visits google" failure="false" error="false" success="true"/>
<testcase name="Second Test Suite can search" time="4.002" classname="can search" failure="false" error="false" success="true"/>
</testsuite>
<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">
<testcase name="First Test Suite visits google" time="0" classname="visits google" failure="true" error="true" success="false">
<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'
at Context.eval (webpack:///./e2e/first.cy.js:4:15)</failure>
</testcase>
<testcase name="First Test Suite can search" time="3.238" classname="can search" failure="false" error="false" success="true"/>
</testsuite>
<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">
<testcase name="Second Test Suite visits google" time="1.174" classname="visits google" failure="false" error="false" success="true"/>
<testcase name="Second Test Suite can search" time="3.156" classname="can search" failure="false" error="false" success="true"/>
<testcase name="First Test Suite can search" time="4.588" classname="can search" failure="false" error="false" success="true"/>
</testsuite>
</testsuites>
11 changes: 11 additions & 0 deletions cy-example/results-9b3c9e70a3ea29bded50339819b55a4d.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="4.915" tests="2" failures="0">
<testsuite name="Root Suite" timestamp="2024-11-20T16:54:33" tests="0" file="cy-example/e2e/second.cy.js" failures="0" time="0">
</testsuite>
<testsuite name="Second Test Suite" timestamp="2024-11-20T16:54:33" tests="2" failures="0" time="4.915">
<testcase name="Second Test Suite visits google" time="1.184" classname="visits google" failure="false" error="false" success="true">
</testcase>
<testcase name="Second Test Suite can search" time="3.731" classname="can search" failure="false" error="false" success="true">
</testcase>
</testsuite>
</testsuites>
13 changes: 13 additions & 0 deletions cy-example/results-cd26ab75fb7fa3716e4f782fc2925e78.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="4.234" tests="2" failures="1">
<testsuite name="Root Suite" timestamp="2024-11-20T16:54:20" tests="0" file="cy-example/e2e/first.cy.js" failures="0" time="0">
</testsuite>
<testsuite name="First Test Suite" timestamp="2024-11-20T16:54:20" tests="2" failures="1" time="4.234">
<testcase name="First Test Suite visits google" time="0" classname="visits google" failure="true" error="true" success="false">
<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'
at Context.eval (webpack:///./e2e/first.cy.js:4:15)]]></failure>
</testcase>
<testcase name="First Test Suite can search" time="4.234" classname="can search" failure="false" error="false" success="true">
</testcase>
</testsuite>
</testsuites>
20 changes: 10 additions & 10 deletions scripts/junitXmlToInstanceJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fs.readFile(xmlFilePath, "utf-8", (err, data) => {

const suiteJson = {
groupId: result.testsuites.name,
spec: suite.file ?? suite.name,
spec: suite.name,
worker: {
workerIndex: 1,
parallelIndex: 1,
Expand All @@ -104,9 +104,7 @@ fs.readFile(xmlFilePath, "utf-8", (err, data) => {
wallClockDuration: durationMillis,
},
tests: testcases.map((test) => {
console.log("FAIL::", test.failure);
const hasFailure = test?.failure && test?.failure !== "false";
console.log("FAILURERES::", extractFailure(test?.failure));
return {
_t: Date.now(),
testId: generateTestId(test?.name, suite.name),
Expand All @@ -131,20 +129,24 @@ fs.readFile(xmlFilePath, "utf-8", (err, data) => {
steps: [],
duration: secondsToMilliseconds(parseFloat(test?.time)),
status: hasFailure ? "failed" : "passed",
stdout: test?.["system-out"] ? [test?.["system-out"]] : [],
stderr: hasFailure ? extractFailure(test?.failure) : [],
stdout: test?.["system-out"]
? [test?.["system-out"]]
: undefined,
stderr: hasFailure
? extractFailure(test?.failure)
: undefined,
errors: hasFailure
? [
mergeFailuresIntoMessage(
extractFailure(test?.failure)
) ?? {},
]
: [],
: undefined,
error: hasFailure
? mergeFailuresIntoMessage(
extractFailure(test?.failure)
) ?? {}
: {},
: undefined,
},
],
};
Expand Down Expand Up @@ -176,15 +178,13 @@ function extractFailure(failure) {
failureArray.push(failure?._);
}
if (Array.isArray(failure)) {
console.log("ENTER::");
let failureItem;
for (let i = 0; i < failure.length; i++) {
if (typeof failure[i] === "object" && failure[i] !== null) {
failureItem = failure[i];
break;
}
}
console.log("FAIL ITEM::", failureItem);
return extractFailure(failureItem);
}
return failureArray;
Expand All @@ -203,5 +203,5 @@ function mergeFailuresIntoMessage(failuresArray) {
}

function secondsToMilliseconds(seconds) {
return Math.round(seconds * 1000);
return seconds * 1000;
}
30 changes: 22 additions & 8 deletions vitest-example/junit.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="6" failures="2" errors="0" time="0.386">
<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">
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; capitalizes first letter of each word" time="0.0011366253">
<testsuites name="vitest tests" tests="12" failures="2" errors="0" time="0.397">
<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">
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; calculates average of positive numbers" time="0.0009692917">
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles already capitalized words" time="0.0001980419">
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; handles array with single number" time="0.0001641254">
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles empty string" time="0.0000864573">
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; handles empty array" time="0.00012675">
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles single word" time="0.0000859175">
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; handles negative numbers" time="0.0000724592">
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles mixed case input" time="0.00472225">
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; handles decimal numbers" time="0.000227417">
</testcase>
<testcase classname="vitest-example/tests/numberUtils.spec.js" name="calculateAverage &gt; returns 0 for invalid input" time="0.0000796661">
</testcase>
</testsuite>
<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">
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; capitalizes first letter of each word" time="0.0008376656">
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles already capitalized words" time="0.000222208">
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles empty string" time="0.000078042">
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles single word" time="0.0000717506">
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; handles mixed case input" time="0.0034179993">
<failure message="expected &apos;Hello World&apos; to be &apos;Hello World!&apos; // Object.is equality" type="AssertionError">
AssertionError: expected &apos;Hello World&apos; to be &apos;Hello World!&apos; // Object.is equality

Expand All @@ -19,7 +33,7 @@ Received: &quot;Hello World&quot;
❯ vitest-example/tests/stringUtils.spec.js:22:44
</failure>
</testcase>
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; errors on number received" time="0.0006915846">
<testcase classname="vitest-example/tests/stringUtils.spec.js" name="capitalizeWords &gt; errors on number received" time="0.0005700846">
<failure message="str.split is not a function" type="TypeError">
TypeError: str.split is not a function
❯ Module.capitalizeWords vitest-example/stringUtils.js:4:6
Expand Down
48 changes: 48 additions & 0 deletions wdio-example/results-1732121752524-0-0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1" errors="0" skipped="0">
<testsuite name="My Login application incorrect" timestamp="2024-11-20T11:55:55" time="5.25" tests="1" failures="1" errors="0" skipped="0">
<properties>
<property name="specId" value="0"/>
<property name="suiteName" value="My Login application incorrect"/>
<property name="capabilities" value="chrome.131_0_6778_85.mac"/>
<property name="file" value="file://./wdio-example/tests/signup.e2e.js"/>
</properties>
<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">
<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;"/>
<system-out><![CDATA[
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.4/clear - {}
RESULT: {}
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.4/value - {"text":"tomsmith"}
RESULT: {"text":"tomsmith"}
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.6/clear - {}
RESULT: {}
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.6/value - {"text":"123"}
RESULT: {"text":"123"}
COMMAND: POST /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.603FDC276C7E6B2DE2B2F05E4F9D6BDA.e.7/click - {}
RESULT: {}
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
RESULT: {}
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
RESULT: {}
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
RESULT: {}
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
RESULT: {}
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
RESULT: {}
COMMAND: GET /session/d508f942d7ce0715a049272f75f5c966/element/f.BAF1F24B5CBDD3534E5773E3374C2986.d.6F3ADC9B60412FBEC2B0CC2606B227EA.e.18/text - {}
RESULT: {}
COMMAND: DELETE /session/d508f942d7ce0715a049272f75f5c966 - {}
RESULT: {}
]]></system-out>
<system-err><![CDATA[
Error: Expect to have text
Expected: StringContaining "You logged into a secure area!"
Received: "Your password is invalid!
×"
at Context.<anonymous> (/Users/miguelangarano/Documents/GitHub/generic-api-example/wdio-example/tests/signup.e2e.js:11:41)
]]></system-err>
</testcase>
</testsuite>
</testsuites>
29 changes: 29 additions & 0 deletions wdio-example/results-1732121752524-0-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="0" errors="0" skipped="0">
<testsuite name="My Login application" timestamp="2024-11-20T11:55:55" time="2.43" tests="1" failures="0" errors="0" skipped="0">
<properties>
<property name="specId" value="0"/>
<property name="suiteName" value="My Login application"/>
<property name="capabilities" value="chrome.131_0_6778_85.mac"/>
<property name="file" value="file://./wdio-example/tests/test.e2e.js"/>
</properties>
<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">
<system-out><![CDATA[
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.4/clear - {}
RESULT: {}
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.4/value - {"text":"tomsmith"}
RESULT: {"text":"tomsmith"}
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.6/clear - {}
RESULT: {}
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.6/value - {"text":"SuperSecretPassword!"}
RESULT: {"text":"SuperSecretPassword!"}
COMMAND: POST /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.ECDD0D49BE555B0547226577CC9AA755.e.7/click - {}
RESULT: {}
COMMAND: GET /session/69b60adbc65a7e265fc3972621eec652/element/f.7DC630A8BB58E2E58F9E88FED88EA3B2.d.752C3C14B55001F6F7728C476DC27EEE.e.15/text - {}
RESULT: {}
COMMAND: DELETE /session/69b60adbc65a7e265fc3972621eec652 - {}
RESULT: {}
]]></system-out>
</testcase>
</testsuite>
</testsuites>

0 comments on commit fe48720

Please sign in to comment.