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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocha reports "expect" reporterOption passed into it #18014

Closed
KamalAman opened this issue Sep 7, 2021 · 6 comments
Closed

Mocha reports "expect" reporterOption passed into it #18014

KamalAman opened this issue Sep 7, 2021 · 6 comments
Labels
stage: ready for work The issue is reproducible and in scope stale no activity on this issue for a long period topic: reporters 📄

Comments

@KamalAman
Copy link

KamalAman commented Sep 7, 2021

Current behavior

Currently, the Cypress integration with mocha assumes that reporters take in an option called reporterOptions however reporterOptions is actually an alias for reporterOption

The current implementation

reporterOptions: this.reporterOptions,

The change to the API is stated here mochajs/mocha#4741 (comment)
and documented here: https://mochajs.org/#-reporter-option-option-o-option-reporter-options-option

That being said, you cannot just pass in reporterOption instead of reporterOptions since some reporters still reference the legacy variable.

Desired behavior

Should be able to use any mocha reporter, and it should respect reporterOptions Cypress CLI parameter.

For example the JSON reporter here uses the new variable reporterOption https://github.com/mochajs/mocha/blob/master/lib/reporters/json.js

Test code to reproduce

In the latest version of the JSON version in v9.11 of mocha it has an output option. Currently the render options do not get properly passed in.

nx affected --target=e2e  --reporter json --reporterOptions "output=results.json"

Cypress Version

8.3.1

Other

The proposed change would be to make the following change

this.reporter = new this.mocha._reporter(this.runner, {
      reporterOptions: this.reporterOptions,
      reporterOption: this.reporterOptions,
})
@sainthkh sainthkh added stage: ready for work The issue is reproducible and in scope topic: reporters 📄 labels Oct 4, 2021
mcasperson added a commit to OctopusSamples/junit-cypress-test that referenced this issue Oct 25, 2021
@patcon
Copy link

patcon commented Apr 27, 2022

I believe I'm hitting this, where mocha reporters can't be output to file:

// cypress.json
{
  "reporter": "json",
  "reporterOption": {
    "mochaFile": "output.txt"
  }
}

Cypress package version: 9.6.0

Wondering if there's a way to force an old version of mocha in the meantime...

@patcon
Copy link

patcon commented Apr 27, 2022

Thanks @KamalAman! Pushed this just a little bit further in #21224 😆

@patcon
Copy link

patcon commented Apr 27, 2022

The breaking commit in mocha:
mochajs/mocha@eed38d7

The attempted backward compat that should ideally work for us: mochajs/mocha@9c10ada

@jholmes-seek
Copy link

Is there anything we can do to help get this through?

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 15, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: ready for work The issue is reproducible and in scope stale no activity on this issue for a long period topic: reporters 📄
Projects
None yet
Development

No branches or pull requests

5 participants