Jest: Expose Already Present Jest Json Reporter

Created on 2 Aug 2019  路  6Comments  路  Source: facebook/jest

Feature Request (edit)

## Bug Report

Included reporters should include Json Jest Reporter
Cannot use --json with other reporters

Jest Json Reporter
https://gist.github.com/nullxone/08c34925cf2f5e1a5123f2fb5837ac11

Motivation

I'm running jest remotely. I want to see the colourful output in my terminal.
I ALSO want the json output to be generated so that I can somehow proceed to send it to my editor / other tools vscode-jest

Pitch

Why does this feature belong in the Jest core platform?

  • Jest already includes this reporter (via --json flag)
  • It should expose it as a named includable reporter like all the other reporters
  • require("jest-util").formatTestResults is not in public api as per docs
  • flag --json can continue to disable other reporters
Bug Report

All 6 comments

It's not really a reporter - it mostly just dumps the test result to stdout. It should be pretty simple to implement as a custom reporter though, have you tried? See https://jestjs.io/docs/en/configuration#reporters-array-modulename-modulename-options. You get the object you're after in onRunComplete

I have implemented the reporter in this gist:
https://gist.github.com/nullxone/08c34925cf2f5e1a5123f2fb5837ac11

Structure output by --json flag is not the same as the format passed to custom reporters. It is defined by require("jest-util").formatTestResults which is not in the public api.

Jest should include the --json flag output structure as a custom reporter because:

  • it behaves like a reporter the structure of which is defined by jest internals
  • it should be possible to get this output alongside running other reporters

The exports of jest-util, while not documented, are considered public API and are safe to use within a major. You can safely depend on it if you want

Thank you. That resolves the issue.

Can this be considered as a feature request? I think this is a good candidate for inclusion in jest for the above mentioned reasons.

I think it might actually be a cleanup to make it a proper reporter and set it up depending on flags instead of the default reporters. wdyt @SimenB?

Would be nice to deprecate the json flag and ask people to do --reporters json instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paularmstrong picture paularmstrong  路  3Comments

Antho2407 picture Antho2407  路  3Comments

jardakotesovec picture jardakotesovec  路  3Comments

hramos picture hramos  路  3Comments

ticky picture ticky  路  3Comments