You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when running Jest with the --json flag, the result will be a stringified Json object, without a trailing newline character.
When running with the --watch or --watchAll flag, Jest will produce an object for every test run. Because those individual results also don't end with a newline character, all those objects will be glued together on the same line.
My proposal is to add a newline character after every Json object, to make it easier to separate test runs.
Motivation
The implication of the current behavior is that it makes it a lot harder to build external integrations that use the output of jest --json --watchAll.
If every test run would result in output ending with a newline, you can parse every line of the stdout as an individual Json test result.
Without newline separators, it becomes a lot harder to separate the test runs in the output, and will in most cases require a custom parse step to find the end of the object.
It also means that the output of jest --json doesn't conform to the Unix file specification, which dictates that all lines in a text file should end with a newline character.
npx jest --json --watchAll 2>/dev/null | python3 ./reporter.py
If the test outputs would end with a newline, the Python file would print for every test run.
Currently, the python file won't print anything, because all run results are appended to the same line.
When the Jest process is terminated, the Python script throws an error because the line cannot be parsed as valid Json (because it contains multiple Json documents).
Pitch
The code that prints the Json representation is in the jest-core package.
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🚀 Feature Proposal
Currently, when running Jest with the
--json
flag, the result will be a stringified Json object, without a trailing newline character.When running with the
--watch
or--watchAll
flag, Jest will produce an object for every test run. Because those individual results also don't end with a newline character, all those objects will be glued together on the same line.My proposal is to add a newline character after every Json object, to make it easier to separate test runs.
Motivation
The implication of the current behavior is that it makes it a lot harder to build external integrations that use the output of
jest --json --watchAll
.If every test run would result in output ending with a newline, you can parse every line of the stdout as an individual Json test result.
Without newline separators, it becomes a lot harder to separate the test runs in the output, and will in most cases require a custom parse step to find the end of the object.
It also means that the output of
jest --json
doesn't conform to the Unix file specification, which dictates that all lines in a text file should end with a newline character.Example
reporter.py:
If the test outputs would end with a newline, the Python file would print for every test run.
Currently, the python file won't print anything, because all run results are appended to the same line.
When the Jest process is terminated, the Python script throws an error because the line cannot be parsed as valid Json (because it contains multiple Json documents).
Pitch
The code that prints the Json representation is in the
jest-core
package.The text was updated successfully, but these errors were encountered: