Skip to content

orangebeard-io/cypress-listener

Repository files navigation

Orangebeard.io Cypress.io Listener
Orangebeard.io Cypress Listener

Orangebeard listener (a service and reporter) for Cypress.io

NPM Version Build Status License

Installation

Install the npm package

npm install @orangebeard-io/cypress-listener

Configuration

In your cypress.config.js file, provide the necessary configuration for the listener and the plugin:

const { defineConfig } = require('cypress');
const registerOrangebeardPlugin = require('@orangebeard-io/cypress-listener/lib/plugin');
const glob = require('glob');
const delay = async (ms) => new Promise((res) => setTimeout(res, ms));

module.exports = defineConfig({
  "reporter": "@orangebeard-io/cypress-listener",
  "reporterOptions": {
    "endpoint": "https://tenant.orangebeard.app",
    "token": "00000000-0000-0000-0000-00000000",
    "testset": "Cypress.io test run",
    "project": "project_name",
    "description": "A description of the test run", 
    "reportVideo": false //optional
  },
    e2e: {
        setupNodeEvents(on, config) {
            // keep Cypress running until the listener has finished sending its async events, preventing unfinished runs in Orangebeard
            on('after:run', async () => {
                console.log('Wait for Orangebeard listener to finish reporting...');
                while (glob.sync('orangebeard-*.lock').length > 0) {
                    await delay(500);
                }
                console.log('Orangebeard listener finished');
            });
            registerOrangebeardPlugin(on, config);
            return config;
        },
    },
    video: true, //optional
});

Running

Now run your tests normally using cypress run and get results in Orangebeard!

Note that when running a subset from the commandline, you will have to use the --config flag, as the --spec flag will not be passed to the reporter, resulting in the reporter to expect all specs in the project and thus not finishing up correctly.

Example:

cypress run --browser chrome --config "specPattern=cypress/e2e/somespec/*.cy.js"

or:

cypress run --browser chrome --config '{"specPattern":["cypress/e2e/somespec/*.cy.js"]}'

Using the --reporter-options or -o flag, it is also possible to provide reporter options from the command line.