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

Fixed an issue with parsing junit reports generated by mocha #42

Merged
merged 1 commit into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/pagerduty/incident.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class JahiaPagerDutyIncident extends Command {
}

// eslint-disable-next-line no-console
this.log('JSON Payload', JSON.stringify(pdPayload))
this.log('JSON Payload for submission', JSON.stringify(pdPayload))

if (testFailures === 0) {
this.log('There are 0 failures in the provided reports, not submitting an incident to pagerduty')
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ingest/parse-xml-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const buildSuites = (xmlSuites: any, testFilename: string) => {
skipped: Math.round(s.attributes.skipped),
testsCount: Math.round(s.attributes.tests),
time: Math.round(s.attributes.time),
tests: buildTest(s.elements.filter((t: any) => t.name === 'testcase')),
tests: s.elements === undefined ? [] : buildTest(s.elements.filter((t: any) => t.name === 'testcase')),
}
})
}
Expand Down
1,220 changes: 1,214 additions & 6 deletions test/__snapshots__/ingest.test.ts.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.9370" tests="1" failures="0">
<testsuite name="Root Suite" timestamp="2021-11-25T15:40:34" tests="0" file="cypress/integration/api/apiDescription.spec.ts" time="0.0000" failures="0">
</testsuite>
<testsuite name="Test if every type in graphQL API has description" timestamp="2021-11-25T15:40:34" tests="1" time="0.8680" failures="0">
<testcase name="Test if every type in graphQL API has description Check every input for the User Type" time="0.3190" classname="Check every input for the User Type">
</testcase>
</testsuite>
</testsuites>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="1.6550" tests="6" failures="0">
<testsuite name="Root Suite" timestamp="2021-11-25T15:40:48" tests="0" file="cypress/integration/api/jcrAddNode.spec.ts" time="0.0000" failures="0">
</testsuite>
<testsuite name="Validate ability get current User" timestamp="2021-11-25T15:40:48" tests="6" time="1.6140" failures="0">
<testcase name="Validate ability get current User User root creating a JCR node - Recommended method" time="0.4570" classname="User root creating a JCR node - Recommended method">
</testcase>
<testcase name="Validate ability get current User User guest creating a JCR node - Recommended method" time="0.0500" classname="User guest creating a JCR node - Recommended method">
</testcase>
<testcase name="Validate ability get current User User root creating a JCR node - Alternative method" time="0.1310" classname="User root creating a JCR node - Alternative method">
</testcase>
<testcase name="Validate ability get current User User guest creating a JCR node - Alternative method" time="0.0370" classname="User guest creating a JCR node - Alternative method">
</testcase>
<testcase name="Validate ability get current User User root creating a JCR node - DO NOT USE" time="0.1880" classname="User root creating a JCR node - DO NOT USE">
</testcase>
<testcase name="Validate ability get current User User guest creating a JCR node - DO NOT USE" time="0.0470" classname="User guest creating a JCR node - DO NOT USE">
</testcase>
</testsuite>
</testsuites>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="1.0960" tests="8" failures="0">
<testsuite name="Root Suite" timestamp="2021-11-25T15:40:41" tests="0" file="cypress/integration/api/currentUser.spec.ts" time="0.0000" failures="0">
</testsuite>
<testsuite name="Validate ability get current User" timestamp="2021-11-25T15:40:41" tests="8" time="1.0580" failures="0">
<testcase name="Validate ability get current User Get Current user for known user (mathias) - Recommended method" time="0.3200" classname="Get Current user for known user (mathias) - Recommended method">
</testcase>
<testcase name="Validate ability get current User Get Current user for known user (root) - Recommended method" time="0.0840" classname="Get Current user for known user (root) - Recommended method">
</testcase>
<testcase name="Validate ability get current User Get Current user for known user (root) with incorrect password - Recommended method" time="0.0850" classname="Get Current user for known user (root) with incorrect password - Recommended method">
</testcase>
<testcase name="Validate ability get current User Get Current user for unknown user - Recommended method" time="0.0740" classname="Get Current user for unknown user - Recommended method">
</testcase>
<testcase name="Validate ability get current User Guest user cannot use the API with default configuration - Recommended method" time="0.0460" classname="Guest user cannot use the API with default configuration - Recommended method">
</testcase>
<testcase name="Validate ability get current User Get Current user for Authenticated user (mathias) - Alternative method" time="0.0690" classname="Get Current user for Authenticated user (mathias) - Alternative method">
</testcase>
<testcase name="Validate ability get current User Get current user non-Authenticated user (guest) - Alternative method" time="0.0540" classname="Get current user non-Authenticated user (guest) - Alternative method">
</testcase>
<testcase name="Validate ability get current User Get Current user for Authenticated user (mathias) - DO NOT USE" time="0.0730" classname="Get Current user for Authenticated user (mathias) - DO NOT USE">
</testcase>
</testsuite>
</testsuites>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="27.6810" tests="1" failures="0">
<testsuite name="Root Suite" timestamp="2021-11-25T15:40:54" tests="0" file="cypress/integration/sandboxTest.spec.ts" time="0.0000" failures="0">
</testsuite>
<testsuite name="Successfully navigates to sandbox app" timestamp="2021-11-25T15:40:54" tests="1" time="27.6190" failures="0">
<testcase name="Successfully navigates to sandbox app successfully navigate to the app" time="26.9160" classname="successfully navigate to the app">
</testcase>
</testsuite>
</testsuites>
7 changes: 6 additions & 1 deletion test/ingest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ describe('Test report ingestion', () => {
})

it('JUnit XML', async () => {
const jrRun = await ingestReport('json', path.resolve(__dirname, './assets/junit'), log)
const jrRun = await ingestReport('xml', path.resolve(__dirname, './assets/junit'), log)
expect(jrRun).toMatchSnapshot()
})

it('Mocha JUnit XML (generated using: mocha-junit-reporter)', async () => {
const jrRun = await ingestReport('xml', path.resolve(__dirname, './assets/mocha-junit'), log)
expect(jrRun).toMatchSnapshot()
})
})