-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
If I run my Mocha tests directly from the command line, they run fine, and the output displays with no problems. But if I try to pipe Mocha's output to another program, the output doesn't all get there; only the beginning of the output ever makes it into the pipe.
I've seen this in several manifestations, but it's easy to reproduce just from the command line. I've reproduced this on two different computers, both running 64-bit Windows 7, the latest version of Node.js installed from the Web site, and the latest Mocha installed with npm install -g mocha
.
If I create a file with just one test in it:
it('works', function() {});
and run it from the command line, I see the expected output:
C:\Temp>mocha test.js
.
✔ 1 tests complete (2ms)
C:\Temp>
But if I pipe its output into any other tool, even something as simple as more
, then Mocha's output is cut off. I only see the line of dots -- sometimes not even that. The summary line isn't shown.
C:\Temp>mocha test.js | more
.
C:\Temp>
If there are failing tests, and you run STDERR through a pipe, then the test-failure information will be cut off:
C:\Temp>mocha fail.js 2>&1 | more
. Γ£û 1 of 1 tests failed:
C:\Temp>
I've also seen this behavior when running Mocha from my text editor (Sublime Text 2) and capturing the output into an output window (the output doesn't all appear); and when writing Node.js code that shells out to Mocha (using child_process.exec
) and captures its STDOUT and STDERR (the output doesn't all get sent). I haven't seen any other app cutting off its output like this in any of these circumstances, but Mocha does it every time its output is a pipe.