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

No mocha console output when using reporter #135

Open
jnaviamtc opened this issue Aug 11, 2020 · 5 comments
Open

No mocha console output when using reporter #135

jnaviamtc opened this issue Aug 11, 2020 · 5 comments

Comments

@jnaviamtc
Copy link

jnaviamtc commented Aug 11, 2020

Currently if I use the --reporter mocha-junit-reporter when calling mocha, the console doesn't show the it('Should...') hooks in the console. At the end of runtime it generates the .xml file for the test no problem.

In prior usage this was not the case. During runtime I could see the current state of the test in the console, with each test showing a check-mark of marked in red if it failed.

So far I have tried:

  • Re installing mocha-junit-reporter locally and globally
  • re-installing mocha in the same manner
  • Tried multiple node files and ways to call from package.json

Any help with this matter is greatly appreciated.

Edit: typos

@binhtho
Copy link

binhtho commented Jan 19, 2021

+1 to this, I am trying out this package and would love to be able to see the output I used to see before in the console. I used to be able to see the test suite summaries and error messages for failures right when the testing is done. Now I would need to open up the generated XML. If the output could be directed to both, that would be great.

@srknzl
Copy link

srknzl commented Apr 28, 2021

Is there a way to show mocha output?

@motin
Copy link

motin commented May 11, 2021

I believe the way to achieve this is to use https://www.npmjs.com/package/mocha-multi-reporters and configure it to use both the spec and mocha-junit-reporters

@cope
Copy link

cope commented Mar 25, 2022

@michaelleeallen can you please comment?

@ousmorez
Copy link

ousmorez commented Oct 24, 2022

@jnaviamtc If you are using mocha js and mocha-junit-reporter. junit causes this problem and blocks your test result output in the terminal because it uses the output to create the XML files and doesn't return the results back, so you can't see the following message in the terminal:

Screenshot (65)

Check your package.json file if your mocha configuration looks like the code below:

  "mocha": {
     .
     .
     .
    "package": "../package.json",
    "reporter": [
      "spec",
      "mocha-junit-reporter"
    ],
     .
     .
     .
    }

You can simply switch the place of spec and mocha-junit-reporter in the package.json file like this:

  "mocha": {
     .
     .
     .
    "package": "../package.json",
    "reporter": [
      "mocha-junit-reporter",
      "spec"
    ],
     .
     .
     .
    }

And that solves the problem.
This workaround disables junit performance because mocha will only use the last reporter you imported. To use two reporters at the same time and see the results of both, you need to use third-party packages like mocha-multi.
After installation, add the following code to your package.json file inside mocha config:

 "mocha": {
    "reporter": "mocha-multi",
    "reporterOptions": "spec=-,mocha-junit-reporter=-",
  },

@binhtho @srknzl @motin @cope

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

No branches or pull requests

6 participants