Prerequisites
Description
There is inconsistent output in browser with json-stream reporter. The start/pass/fail events are printed to stdout as JSON messages but the end event has string 'stdout' prepended to it. I believe that such inconsistency is not necessary.
The inconsistency comes from this line:
|
process.stdout.write(JSON.stringify(['end', self.stats])); |
The end event uses process.stdout.write instead of console.log to print its output. browser-entry module uses the package browser-stdout which optionally prepends a label to console messages. In this case it prepends 'stdout:'.
Steps to Reproduce
- Configure Mocha to use json-stream reported in the browser.
- Run a trivial test case in browser.
- Inspect console output using the page debugger.
Expected behavior: [What you expect to happen]
Events are printed to console as JSON messages.
Actual behavior: [What actually happens]
All events except the end event is printed as JSON messages.
Reproduces how often: [What percentage of the time does it reproduce?]
All the time.
Versions
- The output of
mocha --version and node node_modules/.bin/mocha --version:
mocha --version
bash: mocha: command not found
node node_modules/.bin/mocha --version
5.2.0
- The output of
node --version:
- The version and architecture of your operating system: Debian Stretch amd64
- Your shell (bash, zsh, PowerShell, cmd, etc.): bash
- Your browser and version (if running browser tests): Puppeteer 1.9.0, Chromium 594312, Chrome 67.0.3396.99
- Any other third party Mocha related modules (with versions): none
- The code transpiler being used: none
Prerequisites
faqlabelnode node_modules/.bin/mocha --version(Local) andmocha --version(Global). We recommend avoiding the use of globally installed Mocha.Description
There is inconsistent output in browser with json-stream reporter. The start/pass/fail events are printed to stdout as JSON messages but the end event has string 'stdout' prepended to it. I believe that such inconsistency is not necessary.
The inconsistency comes from this line:
mocha/lib/reporters/json-stream.js
Line 50 in 01171b1
The end event uses
process.stdout.writeinstead ofconsole.logto print its output.browser-entrymodule uses the packagebrowser-stdoutwhich optionally prepends a label to console messages. In this case it prepends 'stdout:'.Steps to Reproduce
Expected behavior: [What you expect to happen]
Events are printed to console as JSON messages.
Actual behavior: [What actually happens]
All events except the end event is printed as JSON messages.
Reproduces how often: [What percentage of the time does it reproduce?]
All the time.
Versions
mocha --versionandnode node_modules/.bin/mocha --version:node --version: