Generating allure reports within your Cypress Test Framework

 

Generating allure reports within your Cypress Test Framework

When running cypress automation in background we can use allure reports to view the results of pass fail status. In this blog post I will show the steps of how we can generate allure reports.

As a first step we need to follow the below steps for configuring allure reports in our cypress test framework.

First Step: we need to install allure report

npm i -D @shelex/cypress-allure-plugin

Second Step: Add the below lines to the index.js file inside the plugins folder

const allureWriter = require('@shelex/cypress-allure-plugin/writer');

module.exports = (on, config) => {
    allureWriter(on, config);
    return config;
};

Third Step: Inside the cypress/suport/index.js file add the below line
import '@shelex/cypress-allure-plugin';

Inside the plugins folder we have an index.js to that add the below line
/// <reference types="@shelex/cypress-allure-plugin" />

Fourth Step: Create a folder inside the cypress test framework with any name ex:allure-results

Once the initial configurations are done we need to run the test in background. For this I will use the npx run command as below

Fifth Step: run the command to invoke a single spec file as :
npx cypress run --spec "cypress/integration/RegisterDoctor.js" --env allure=true,allureResultsPath=cypress/allure-results

if we break the above command into multiple parts, the first part of npx cypress run is to run the locally installed cypress. The --spec is used to call a single spec file and lastly the --env is to pass the environment variable with cypress and that the results of the run should be captured for allure reports.


Sixth Step from the location where the allure report generator is added run the below command

allure generate 'available report folder path'  --clean && allure open

The allure report generator will load an html page as below with the results of the test




Comments