GitHub action is missing the JSON report after the Cypress tests finish

396 Views Asked by At

I am trying to setup a GitHub workflow for executing the Cypress tests in parallel using the cypress-split package to split up the tests. My GitHub repository is also part of a GitHub Enterprise organization (not sure if it is relevant, but wanted to mention it since it might be part of the reason I am having this issue).

The problem is that at the end of the test execution I am getting messages like:

Could not find spec results for ./cypress/e2e/demo.cy.ts

and there is no test summary data in the workflow:

enter image description here

I also tried to setup the cypress.config.ts file to use cypress-mochawesome-reporter:

  reporter: 'cypress-mochawesome-reporter',
  reporterOptions: {
    reporterEnabled: 'cypress-mochawesome-reporter',
    cypressMochawesomeReporterReporterOptions: {
      reportDir: './cypress/reports',
      reportFilename: `results-${process.env.SPLIT_INDEX ?? 0}`,
      saveHtml: false,
      saveJson: true,
      saveAllAttempts: false,
      quiet: true,
    },
  },

and during the test execution I can see the following messages:

[mochawesome] Report JSON saved to /home/runner/work/demo-project/cypress/reports/html/.jsons/mochawesome_001.json

However, after the tests finish I have a step for printing the whole structure of the project:

      - name: Verify test project
        if: always()
        run: tree .

and I cannot find the final json, even the files from cypress/reports/html/.jsons/ are no longer there (which would be expected if they were merged into one, but there is no other file).

My project doesn't have the Cypress github action whitelisted, so I am starting the project like this:

      - name: Install Cypress binary
        run: npx cypress install

      - name: Executing tests 
        run: npm run cypress:run

Does anyone have any idea what could be the issue and how to fix this?

0

There are 0 best solutions below