JSON reporter doesn't write output to file
swaroopsm opened this issue · comments
Hi,
Following is my grunt task definition:
mocha: {
test: {
dest: 'output.json',
options: {
run: true,
urls: ['http://localhost:8888/test/example1'],
reporter: 'JSON'
}
}
}
However, when I run this task, I'm able to see the JSON output on the console, but my output.json
file remains empty.
have you tried without dest
? have you tried making dest: './output.json'
?
I'm seeing this too.
I think it has something to do with the fact that some reporters use console.log, while others use process.stdout.write. The source code for grunt-mocha (0.4.13) only appears to hijack console.log
Any word on this? If I have time I'll fiddle with it but for now I'm using grunt-shell-spawn
to just run the mocha command. :-P
The JSON reporter is the only one that doesn't output using console.log
and instead uses process.stdout.write
... which is problematic since we don't want to output everything from stdout into the output file. At this point I don't have an easy solution, if anyone else has ideas please let me know.
Oh wait, I forgot that we used to hijack stdout instead of console but then switched back because it broke old versions of mocha. Master is now on mocha 2.x so we can hijack stdout again.