reportportal / agent-js-cypress

Agent to integrate Cypress with ReportPortal.
https://www.npmjs.com/package/@reportportal/agent-js-cypress
Apache License 2.0
39 stars 39 forks source link

How to send cypress-terminal-report logs to report portal #209

Open shiglikiran opened 2 weeks ago

shiglikiran commented 2 weeks ago

Hello,

we use cypress (latest version) to run UI automated tests in Github which is then configured with Report portal to view test results. I am able to print logs using cypress-terminal-report in the console; however just wanted to know if there's any way to push these logs to report portal as well.

Thanks!

AmsterGet commented 2 weeks ago

Hello @shiglikiran ! By default, agent-js-cypress captures all logs coming from the cy.log command. In addition you can use agent commands for additional log reporting. According to the cypress-terminal-report documentation, it outputs more detailed information, and currently agent-js-cypress does not catch such a dataset. So there is no built-in option to support this, but you could try extending the agent's capabilities to do so.

KiranShigli commented 2 weeks ago

@AmsterGet Many thanks for taking a look at this. However, I'm aware of these agent commands from Cypress but there's no examples around how to use these commands and push them to report portal. If you could provide any leads that would be helpful. Below is exercept from config just in case if it helps

 if (process.env.CI) {
    config.reporter = '../../node_modules/@reportportal/agent-js-cypress'
    config.reporterOptions = {
      skippedIssue: false,
      endpoint: Constants.reportPortalEndpoint,
      apiKey: process.env.RP_API_KEY,
      launchId: JSON.parse(process.env.LAUNCH_INFO)[clientId],
      project: Constants.testProject,
      debug: true,
    }
  }
module.exports = defineConfig({
  e2e: {
    numTestsKeptInMemory: process.env.CI ? 0 : 50,
    experimentalMemoryManagement: true,
    setupNodeEvents,
    specPattern: sharding(
      'cypress/e2e/features/',
      `${process.env.SPEC_NAME || '*.feature'}`,
    ),
    excludeSpecPattern: [],
    baseUrl: 'http://to-be-replaced-from-sys-env',
    userAgent: process.env.ENVIRONMENT === 'prod' ? 'SCM EPAM Testing' : null,
    supportFile: 'cypress/support/e2e_cucumber.ts',
    video: false,
    chromeWebSecurity: false,
     experimentalInteractiveRunEvents: true,
    retries: {
      // Default is 0
      runMode: 1, // Configure retry attempts for `cypress run`
      openMode: 0, // Configure retry attempts for `cypress open`
    },
    env: {
      rpEnable: true,
      tags: process.env.TAGS,
    },
    reporterOptions: {
      debug: true,
    },
  },
  video: false,
  filterSpecs: true,  
})