Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

JSON reporter doesn't write output to file #145

Open
swaroopsm opened this issue Apr 23, 2015 · 5 comments
Open

JSON reporter doesn't write output to file #145

swaroopsm opened this issue Apr 23, 2015 · 5 comments

Comments

@swaroopsm
Copy link

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.

@kmiyashiro
Copy link
Owner

have you tried without dest? have you tried making dest: './output.json'?

@mswinson
Copy link

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

@trezy
Copy link

trezy commented Nov 23, 2015

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

@kmiyashiro
Copy link
Owner

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.

@kmiyashiro
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants