cypress-sonarqube-reporter icon indicating copy to clipboard operation
cypress-sonarqube-reporter copied to clipboard

Uncaught error breaks Sonar scan: Missing attribute "path" in element "file"

Open jacobweberbowery opened this issue 2 years ago • 2 comments

Describe the bug Certain errors result in <file> elements with no path attribute.

To Reproduce I don't have a case I can share right now. But the resulting cypress-sonarqube-reports.all.xml file starts with:

<?xml version="1.0" encoding="utf-8"?>
<testExecutions version="1">
  <file>
    <testCase name="- An uncaught error was detected outside of a test" duration="209">
      <error message="ChunkLoadError: The following error originated from your test code, not from Cypress.&#xA;&#xA;  > Loading chunk ...

and when I run the Sonar scan, I get:

INFO: Parsing /github/workspace/dist/cypress-sonarqube-reports.all.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:20.209s
ERROR: Error during SonarScanner execution
INFO: Final Memory: 22M/77M
ERROR: Error during parsing of generic test execution report '/github/workspace/dist/cypress-sonarqube-reports.all.xml'. Look at the SonarQube documentation to know the expected XML format.
INFO: ------------------------------------------------------------------------
ERROR: Caused by: Missing attribute "path" in element "file" at line 3
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Expected behavior Not sure what should happen in this case.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Github ubuntu-latest runner
  • Browser: Electron
  • Version: latest

Additional context cypress-sonarqube-reporter 1.13.0

jacobweberbowery avatar Nov 15 '23 17:11 jacobweberbowery

Hi @jacobweberbowery, it seems that something went wrong during reporter executiion. Do you have something more to share from the build console output? or from the generated XML file? Your XML report extract seems to be cut on the error message that could be interesting...

BBE78 avatar Nov 16 '23 13:11 BBE78

@BBE78 I'll post the rest of it here. But I was reporting this because of the structure of the final XML file, not to find the cause of the original error. (Although if you know that, I'd be glad to hear it!). Since Sonar requires a path, I'm not sure what it should do with this kind of error, which happens outside of a test. You could omit these results, but you'd lose valuable information. Maybe the reporter should just fail, since it can't generate a valid Sonar file?

<?xml version="1.0" encoding="utf-8"?>
<testExecutions version="1">
  <file>
    <testCase name="- An uncaught error was detected outside of a test" duration="209">
      <error message="ChunkLoadError: The following error originated from your test code, not from Cypress.&#xA;&#xA;  > Loading chunk src___test__utils_ts-node_modules_material-ui-pickers_utils_moment-utils_js failed.&#xA;(error: http://localhost:8080/__cypress/src/src___test__utils_ts-node_modules_material-ui-pickers_utils_moment-utils_js.js)&#xA;&#xA;When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.&#xA;&#xA;Cypress could not associate this error to any specific test.&#xA;&#xA;We dynamically generated a new test to display this failure.">
<![CDATA[ChunkLoadError: The following error originated from your test code, not from Cypress.

  > Loading chunk src___test__utils_ts-node_modules_material-ui-pickers_utils_moment-utils_js failed.
(error: http://localhost:8080/__cypress/src/src___test__utils_ts-node_modules_material-ui-pickers_utils_moment-utils_js.js)

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.
    at __webpack_require__.f.j (http://localhost:8080/__cypress/src/main.js:3013:29)
    at <unknown> (http://localhost:8080/__cypress/src/main.js:2863:40)
    at Array.reduce (<anonymous>)
    at __webpack_require__.e (http://localhost:8080/__cypress/src/main.js:2862:67)
    at Object.load (http://localhost:8080/__cypress/src/main.js:38:1132)
    at <unknown> (http://localhost:8080/__cypress/runner/cypress_runner.js:110803:21)
    at tryCatcher (http://localhost:8080/__cypress/runner/cypress_runner.js:1807:23)
    at Object.gotValue (http://localhost:8080/__cypress/runner/cypress_runner.js:6476:18)
    at Object.gotAccum (http://localhost:8080/__cypress/runner/cypress_runner.js:6465:25)
    at Object.tryCatcher (http://localhost:8080/__cypress/runner/cypress_runner.js:1807:23)]]>
      </error>
    </testCase>
  </file>

jacobweberbowery avatar Nov 16 '23 17:11 jacobweberbowery