michaelleeallen / mocha-junit-reporter

A JUnit XML reporter for mocha.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No mocha console output when using reporter

jnaviamtc opened this issue · comments

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

+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.

Is there a way to show mocha output?

commented

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

@michaelleeallen can you please comment?

commented

@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