michaelleeallen / mocha-junit-reporter

A JUnit XML reporter for mocha.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError: Cannot read properties of undefined (reading 'length')

Pverma96 opened this issue · comments

i am using mocha-multi-reporters in my mocha tests and generating mochawesome and mocha-junit-reports. When using --parallel flag, mocha-junit-reporter throws error:

Uncaught error outside test suite:
Uncaught TypeError: Cannot read properties of undefined (reading 'length')
at isInvalidSuite (node_modules/mocha-junit-reporter/index.js:155:62)
at MochaJUnitReporter._onSuiteBegin (node_modules/mocha-junit-reporter/index.js:232:10)
at MochaJUnitReporter. (node_modules/mocha-junit-reporter/index.js:239:17)
at ParallelBufferedRunner.emit (node:events:530:35)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.allSettled (index 0)

command used to run the tests is:

./node_modules/mocha/bin/mocha.js --config .mocharc.cjs --parallel --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --require mochawesome/register --exit test/**/*.spec.js

below is the reporter config file:

{
"reporterEnabled": "mochawesome, mocha-junit-reporter",
"mochawesomeReporterOptions": {
"reportDir": "results/mochawesome",
"overwrite": false,
"html": true,
"json": true,
"toConsole": true,
"consoleReporter": "spec"
},
"mochaJunitReporterReporterOptions": {
"mochaFile": "results/junit/test-results.xml"

}

noticed that if i remove "--require mochawesome/register" flag, i get same error as defined in #178

Version:
"mochawesome": "^7.1.3",
"mocha-junit-reporter": "2.2.0",
"mocha-multi-reporters": "^1.5.1"
"mocha": "^10.4.0",