Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand --json output when using --verbose #1900

Closed
orta opened this issue Oct 9, 2016 · 5 comments
Closed

Expand --json output when using --verbose #1900

orta opened this issue Oct 9, 2016 · 5 comments

Comments

@orta
Copy link
Member

orta commented Oct 9, 2016

Do you want to request a feature or report a bug?

Feature.

I'm building out tooling for VS Code, to highlight tests inline and ideally would like to be able to do this based on the output of --json.

Currently the test JSON gives a lot of information about the suites, but I'd like to get a bit more fine-grained information. For example, I would like to know:

  • Test file
  • Test LOC
  • Test name
  • Test time
  • Test Status (passed/failed/skipped)
  • Test Error Message

This is the sort of stuff normally used in junit-esk reporters, with line of code being an extra

What is the current behavior?

node_modules/.bin/jest --debug --json --verbose

{
    "success": true,
    "startTime": 1476014813818,
    "numTotalTests": 1,
    "numTotalTestSuites": 1,
    "numRuntimeErrorTestSuites": 0,
    "numPassedTests": 1,
    "numFailedTests": 0,
    "numPendingTests": 0,
    "testResults": [
        {
            "name": "/Users/orta/dev/projects/vscode/jest/examples/getting_started/__tests__/sum-test.js",
            "summary": "",
            "message": "",
            "status": "passed",
            "startTime": 1476014814377,
            "endTime": 1476014814663
        }
    ]
}

What is the expected behavior?

The above is what you would see without --verbose and with --verbose it would be:

node_modules/.bin/jest --debug --json --verbose

...
    "numPendingTests": 0,
    "testResults": [
        {
            "name": "/Users/orta/dev/projects/vscode/jest/examples/getting_started/__tests__/sum-test.js",
            "summary": "",
            "message": "",
            "status": "passed",
            "startTime": 1476014814377,
            "endTime": 1476014814663,
            "testCases": [
                {
                    "name": "adds 1 + 2 to equal 3",
                    "status": "passed",
                    "time": 0.000093,
                    "file": "/Users/orta/dev/projects/vscode/jest/examples/getting_started/__tests__/sum-test.js",
                    "line": 345,
                    "message" : null
                }
            ]
        }

I don't know for certain whether the rest results are directly matched to a specific file, if it is, then "file" could be removed from the test cases and only line would be needed.

WRT error messages, the current message is for the whole suite, and so it would be hard to pull out specific metrics for an individual test, so Iv'e adde dit into the JSON example.

Does this feel reasonable? ( Or is there some JS-y standard I don't know of that I can make this conform to? I'm pretty new to the ecosystem. )

@orta
Copy link
Member Author

orta commented Oct 9, 2016

Sidenote: I'm very willing to make this myself, I maintain the biggest test runner in Objective-C, so I should try to understand the internals of our JS stuff more. I'm much more interested in whether this is something that'd be merged or not

Other note: I feel like I'd also want the line of the raised exception if there was a failure. So, maybe "message" or "status" could be structured data? e.g.

"status": { "state":  "passed" }
...
"status": { "state":  "failed", "message":"Expected 'x' got 'y'", "line": 345 }
...
"status": { "state":  "skipped" }

@cpojer
Copy link
Member

cpojer commented Oct 21, 2016

@orta I'm totally happy to support this if you send a PR. If the data is big and takes a lot of time to calculate, I'd prefer it to only happen with the verbose flag. Otherwise, if it's quick to compute and not that much more info than we already have, feel free to expand the existing --json behavior with all the information you think is valuable. We can then discuss on the PR about specifics :)

@cpojer
Copy link
Member

cpojer commented Oct 28, 2016

I'm going to close this issue because by itself it isn't actionable and it isn't on our internal roadmap. Please feel free to keep sending PRs and extend the --json output as you see fit.

@cpojer cpojer closed this as completed Oct 28, 2016
@orta
Copy link
Member Author

orta commented Oct 28, 2016

Perfect, I was going to do that when that PR merged 👍

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants