qase-tms / qase-javascript

Qase TMS JavaScript SDK
https://developers.qase.io
47 stars 38 forks source link

[qase-cypress-v2] Error when using the reporter without `cypress-multi-reporters` #597

Open gibiw opened 1 month ago

gibiw commented 1 month ago

If you do not use cypress-multi-reporters, an error appears when running tests.

'[object Object]' reporter not found
invalid reporter '[object Object]'
TypeError: invalid reporter '[object Object]'
    at createInvalidReporterError (<embedded>:2764:123502)
    at k.reporter (<embedded>:2769:3431)
    at new k (<embedded>:2769:1480)
    at A.setRunnables (<embedded>:4445:15437)
    at Object.onTestsReceivedAndMaybeRecord (<embedded>:4498:28550)
    at p.<anonymous> (<embedded>:4445:47245)
    at p.emit (node:events:514:28)
    at <embedded>:4445:26630
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Example of cypress config:

const cypress = require('cypress');
const plugins = require('./cypress/plugins/index.js');

module.exports = cypress.defineConfig({
  reporter: 'cypress-qase-reporter',
  reporterOptions: {
    mode: 'testops',
    debug: true,
    testops: {
      api: {
        token: 'token',
      },

      project: 'project_code',
      uploadAttachments: true,
      run: {
        complete: true,
      },
    },

    framework: {
      cypress: {
        screenshotsFolder: 'cypress/screenshots',
      },
    },

  },
  video: false,
  e2e: {
    setupNodeEvents(on, config) {
      return require('./cypress/plugins/index.js')(on, config);
    },
  }
});

As a workaround use cypress-multi-reporters.

NickVolynkin commented 1 month ago

Solution: use the cypress-multi-reporters config.

Using other reporters is entirely optional: it works with multiple reporters and with just

import cypress from 'cypress';

import plugins from './cypress/plugins/index.js';

module.exports = cypress.defineConfig({
+  reporter: 'cypress-multi-reporters',
-  reporter: 'cypress-qase-reporter',
  reporterOptions: {
+    reporterEnabled: 'cypress-qase-reporter',
+    cypressQaseReporterReporterOptions: {
      mode: 'testops'
      debug: true,

      testops: {
        api: {
          token: 'api_key',
        },
        project: 'project_code',
        uploadAttachments: true,

        run: {
          complete: true,
        },
      },

      framework: {
        cypress: {
          screenshotsFolder: 'cypress/screenshots',
        }
      }
    },
+  },
  video: false,
  e2e: {
    // We've imported your old cypress plugins here.
    // You may want to clean this up later by importing these.
    setupNodeEvents(on, config) {
      return plugins(on, config);
    },
  },
});