question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a guide/example on setup with multiple-cucumber-html-reporter

See original GitHub issue

Hey guys,

I just started using cypress-cucumber-preprocessor at work and it’s a great tool (thanks for that!), but the thing that I am missing is the possibility to also generate a nice html report at the end of a test run.

The README file says that it should work fine with multiple-cucumber-html-reporter, but I did not manage to make it work. Any chance you might add a guide or an example on this?

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
jcundillcommented, Feb 26, 2020

Firstly configure package.json to generate cucumber.json files when cypress is run - see https://github.com/TheBrainFamily/cypress-cucumber-preprocessor#output

install the multi-html-reporter into your project npm install multiple-cucumber-html-reporter --save-dev

write a helper script to invoke the reporter as described in https://github.com/wswebcreation/multiple-cucumber-html-reporter#cucumber-js-3x - so copy the code block shown above this as a separate js file in your project - report.js, for example

make sure the jsonDir in this helper points to the directory you told the plugin to write the cucumber json files to in package.json

run the features npx cypress run --spec "cypress/integration/*.feature"

check there are a bunch of json files in the folder you specified

run the reporter node report.js

open index.html in the output folder

Screenshot 2020-02-26 at 20 08 18
4reactions
thierryiselicommented, Aug 14, 2021

``> In addition to what @JoaoPedroVarella is looking for, I am looking for including Metadata in my html report but so far, I have not been able to do it in MacOS. Anyone who has tried including all metadata for Mac?

image

I started to handle it in this way, I save the cypress run as json, my cypress/plugins/index.js:

const cucumber = require('cypress-cucumber-preprocessor').default
const fs = require('fs');

module.exports = (on, config) => {
  on('file:preprocessor', cucumber()),
  on('after:run', (results) => {
    if (results) {
      fs.mkdirSync("cypress/.run", { recursive: true });
      fs.writeFile("cypress/.run/results.json", JSON.stringify(results));
    }
  })
}

Then I consume this json for generating the html report, for this case I added this to my report generator js:

const report = require('multiple-cucumber-html-reporter');
const fs = require('fs');

const mapOs = (os) => {
    if(os.startsWith('win')) {
        return 'windows';
    } else if (os.startsWith('osx')) {
        return 'osx';
    } else if (os.startsWith('linux')) {
        return 'linux';
    } else if (os.startsWith('ubuntu')) {
        return 'ubuntu';
    } else if (os.startsWith('android')) {
        return 'android';
    } else if (os.startsWith('ios')) {
        return 'ios';
    }
};

fs.readFile('cypress/.run/results.json', function read(err, data) {
    if (err) {
        throw err;
    }
    var runInfos = JSON.parse(data);
    report.generate({
        jsonDir: './cypress/result/',
        reportPath: './cypress/report/',
        metadata:{
            browser: {
                name: runInfos.browserName,
                version: runInfos.browserVersion
            },
            device: 'Cypress',
            platform: {
                name: mapOs(runInfos.osName)
            }
        },
        customData: {
            title: 'Run info',
            data: [
                {label: 'Project', value: 'project'},
                {label: 'Execution Start Time', value: new Date(runInfos.startedTestsAt).toLocaleString()},
                {label: 'Execution End Time', value: new Date(runInfos.endedTestsAt).toLocaleString()}
            ]
        }
    });
});

It’s only a way that I tried, it’s more like a poc. But maybe it’s helpful.
Report looks like this: cucumber-html The things that I didin’t get from cypress run is os version and more device details.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add a guide/example on setup with multiple-cucumber-html ...
Hey guys, I just started using cypress-cucumber-preprocessor at work and it's a great tool (thanks for that!), but the thing that I am...
Read more >
multiple-cucumber-html-reporter - npm
Multiple Cucumber HTML Reporter is a reporting module for Cucumber to parse the JSON output to a beautiful report. The difference between all ......
Read more >
Multiple Cucumber HTML reporter in Cypress
– To generate the final html report just execute your test cases and Refresh the project. This module converts Cucumber's JSON format to...
Read more >
Automated HTML Reports with Cypress 10+ & Cucumber? Repo
Repo: https://github.com/JoanEsquivel/cypress- cucumber - ... AUTOMATE your TESTS REPORTS with CYPRESS 10+ & CUCUMBER | HTML Report.
Read more >
multiple-cucumber-html-reporter Code Examples - Snyk
To help you get started, we've selected a few multiple-cucumber-html-reporter examples, based on popular ways it is used in public projects. Secure your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found