WasiqB/multiple-cucumber-html-reporter

Getting `TypeError: JSON.parse(...).map is not a function`

rakeshnambiar opened this issue · 1 comments

Environment (please complete the following information):

  • multiple-cucumber-html-reporter: latest
  • Node.js version: v19.2.0
  • NPM version: 8.19.3
  • Platform name and version: MAC
  • Cucumber version: cypress-cucumber-preprocessor:(latest)

Config of multiple-cucumber-html-reporter

//const report = require('multiple-cucumber-html-reporter');
import report from "multiple-cucumber-html-reporter"

report.generate({
	jsonDir: './',
	reportPath: './cucumber-report/',
	metadata:{
       browser: {
           name: 'chrome',
           version: '60'
       },
       device: 'Local test machine',
       platform: {
           name: 'ubuntu',
           version: '16.04'
       }
   },
   customData: {
       title: 'Run info',
       data: [
           {label: 'Project', value: 'Custom project'},
           {label: 'Release', value: '1.2.3'},
           {label: 'Cycle', value: 'B11221.34321'},
           {label: 'Execution Start Time', value: 'Nov 19th 2017, 02:31 PM EST'},
           {label: 'Execution End Time', value: 'Nov 19th 2017, 02:56 PM EST'}
       ]
   }
});

Describe the bug

TypeError: JSON.parse(...).map is not a function

> report
> node ./cypress/generate-reports/report.mjs

~/GitHub/browserify-esm/node_modules/multiple-cucumber-html-reporter/lib/collect-jsons.js:36
            JSON.parse(data).map(json => {
                             ^

TypeError: JSON.parse(...).map is not a function
    at ~/GitHub/browserify-esm/node_modules/multiple-cucumber-html-reporter/lib/collect-jsons.js:36:30
    at Array.map (<anonymous>)
    at collectJSONS (~/GitHub/browserify-esm/node_modules/multiple-cucumber-html-reporter/lib/collect-jsons.js:30:15)
    at Object.generateReport [as generate] (~/GitHub/browserify-esm/node_modules/multiple-cucumber-html-reporter/lib/generate-report.js:78:23)
    at file://~/GitHub/browserify-esm/cypress/generate-reports/report.mjs:4:8
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Node.js v19.2.0

To Reproduce
Steps to reproduce the behavior:

Clone and use the project https://github.com/badeball/cypress-cucumber-preprocessor/tree/master/examples/browserify-esm
Set up the https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/json-report.md#json-reports
Generate the JSON report by running npx cypress run command
Create a JS file and copy the contents from https://github.com/wswebcreation/multiple-cucumber-html-reporter
Adjust the path/directory and run this JS file

Alternatively you can clone the repository:
https://github.com/rakeshnambiar/cypress-bdd-cucumber

Expected behavior
I would expect the html reports are generated successfully from the JSON file.

Log
attached above

this is working after I moved the JSON files to a separate directory