Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make mocha-multi-reporters work with Mocha 6 #58

Closed
wants to merge 14 commits into from
Closed

fix: Make mocha-multi-reporters work with Mocha 6 #58

wants to merge 14 commits into from

Conversation

YOU54F
Copy link
Contributor

@YOU54F YOU54F commented Mar 27, 2019

Mocha 6 introduced breaking changes in v6.0 specifically around reporters

https://github.com/mochajs/mocha/releases/tag/v6.0.0

the particular breaking change for reporters - mochajs/mocha#3458

PR tracking the mocha 6 upgrade and failing CI test run

YOU54F/template-cypress-docker-typescript#15

TypeError: Cannot read property 'failures' of undefined
    at MochaJUnitReporter.getXml (/root/app/e2e/node_modules/mocha-junit-reporter/index.js:291:22)
    at MochaJUnitReporter.flush (/root/app/e2e/node_modules/mocha-junit-reporter/index.js:238:18)
    at MochaJUnitReporter.<anonymous> (/root/app/e2e/node_modules/mocha-junit-reporter/index.js:144:10)
    at emitOne (events.js:120:20)
    at Runner.emit (events.js:210:7)
    at Reporter.emit (/root/.cache/Cypress/3.1.3/Cypress/resources/app/packages/server/lib/reporter.js:239:55)
    at Object.server.startWebsockets.onMocha (/root/.cache/Cypress/3.1.3/Cypress/resources/app/packages/server/lib/project.js:296:22)
    at Socket.<anonymous> (/root/.cache/Cypress/3.1.3/Cypress/resources/app/packages/server/lib/socket.js:237:36)
    at emitTwo (events.js:125:13)
    at Socket.emit (events.js:213:7)
    at /root/.cache/Cypress/3.1.3/Cypress/resources/app/packages/socket/node_modules/socket.io/lib/socket.js:503:12
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

I have created forks of mocha-multi-reporter and mocha-junit-reporter and applied the fix in my cypress test suite, pulling in the forked repos with fixes applied and everything is working end to end now including mochawesome reporting.

Test runs are now passing 馃憤 would need a major version release, as it will be a breaking change for any users with mocha versions below 6.

https://circleci.com/gh/YOU54F/cypressio-docker-typescript/95

@coveralls
Copy link

coveralls commented Mar 28, 2019

Coverage Status

Coverage decreased (-3.7%) to 92.784% when pulling 604cce5 on YOU54F:mocha6fix into 807dfa1 on stanleyhlng:master.

@YOU54F
Copy link
Contributor Author

YOU54F commented Apr 3, 2019

@stanleyhlng - would you be up for releasing this on a major version bump? I can create some release notes if you want?

@YOU54F YOU54F changed the title fix: Make mocha-junit-reporter work with Mocha 6 fix: Make mocha-multi-reporters work with Mocha 6 Apr 10, 2019
@aboe026
Copy link

aboe026 commented Apr 25, 2019

bump. It would be nice to have this as I'm seeing the same error with mocha 6+.

@YOU54F
Copy link
Contributor Author

YOU54F commented May 6, 2019

I've now updated, tested and released updated modules that fix this with mocha 6, but also retains backwards compatibility with mocha 5 and earlier versions.

https://www.npmjs.com/package/cypress-multi-reporters
https://www.npmjs.com/package/mocha-junit-reporters

Example against Mocha 5
Example against Mocha 6

the changes required are minimal

npm i mocha-junit-reporters
npm i cypress-multi-reporters

in reporterOpts.json

{
  "reporterEnabled": "mocha-junit-reporters, mochawesome",
  "mochaJunitReportersReporterOptions": {
    "mochaFile": "cypress/reports/junit/test_results[hash].xml",
    "toConsole": false
  },
  "mochawesomeReporterOptions": {
    "reportDir": "cypress/reports/mocha",
    "quiet": true,
    "overwrite": false,
    "html": false,
    "json": true
  }
} 

in cypress.json

{
  ...
  "reporter": "cypress-multi-reporters",
  "reporterOptions": {
    "configFile": "reporterOpts.json"
  }

See https://github.com/YOU54F/cypress-docker-typescript/pull/22/files

Hopefully the PR's will be merged in the source repo's soon but for now, enjoy

@aboe026
Copy link

aboe026 commented May 30, 2019

@YOU54F looks like code coverage decreased

@YOU54F
Copy link
Contributor Author

YOU54F commented May 30, 2019

@YOU54F looks like code coverage decreased

Yeah, I didn't stick a test in, I should but got other things to do =D it's well tested on my side on my local projects. Doesn't look like this is ever going to get merged as the repo owner doesn't seem to be contributing anymore, so I just published my own package.

@YOU54F
Copy link
Contributor Author

YOU54F commented Jun 5, 2019

I've deleted my fork now, the following commits will need reverting

c1e4ecf
ebf094e
8f8791c
604cce5

these changes are published on cypress-multi-reporters now

@YOU54F YOU54F closed this Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants