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

Feature Request: JSON output #514

Open
petermikitsh opened this issue Feb 2, 2022 · 4 comments
Open

Feature Request: JSON output #514

petermikitsh opened this issue Feb 2, 2022 · 4 comments
Labels

Comments

@petermikitsh
Copy link

petermikitsh commented Feb 2, 2022

It would be useful if Chromatic CLI could output, for example, something like this (note: I am open to whatever JSON shape the Chromatic team would prefer):

{
  "statusCode": 1,
  "statusKey": "BUILD_HAS_CHANGES",
  "reviewUrl": "https://www.chromatic.com/build?appId=[REDACTED]&number=2",
}

I could then parse this with a tool like jq and leave a comment on my PR using the gh cli.

OUTPUT=$(npx --no-install chromatic --project-token=REDACTED)

REVIEW_URL=$(echo '$OUTPUT' | jq -r '.reviewUrl')

gh pr comment $CHANGE_ID \
  -b "[BOT] <details><summary>Your PR has visual diff failures:</summary>$REVIEW_URL</details>" \
  --repo $GIT_REPO_PATH
@kylesuss
Copy link
Contributor

kylesuss commented Feb 5, 2022

Hi @petermikitsh 👋

Do you just want the format to be JSON for ease in parsing? Is there any extra information in the JSON object compared to the current output?

@petermikitsh
Copy link
Author

Do you just want the format to be JSON for ease in parsing?

Correct, yes! To expand on the request, I would imagine the CLI would expect some sort of output parameter, eg:

- OUTPUT=$(npx --no-install chromatic --project-token=REDACTED)
+ OUTPUT=$(npx --no-install chromatic --project-token=REDACTED --output json)

Is there any extra information in the JSON object compared to the current output?

I'm still familiarizing myself with the CLI, but the main pieces of useful output would be:

  • total number of test cases
  • number of passing cases
  • number of failing cases
  • percentage of passing test cases
  • link to the review url

Taking a step back, I just want to be able to effectively utilize a PR comment as a call-to-action for developers, so they don't have to dig through the log output to identify the reason of why their build is failing.

I'm migrating my projects from puppeteer storyshots to Chromatic. In this existing workflow, the PR comment on failure would look something like this, and developers would know to push another commit with updated baseline images:

Screen Shot 2022-02-07 at 8 05 27 PM

@tmeasday
Copy link
Member

tmeasday commented Feb 8, 2022

@petermikitsh have you seen the --junit-report flag? This is a fairly standard output format that I think contains the info you need.

@codykaup codykaup added the CLI label Nov 1, 2024 — with Linear
@codykaup
Copy link
Contributor

codykaup commented Nov 4, 2024

We've had a few requests for something like this. I wrote up an internal project so we can discuss adding this feature in the future. Unfortunately, there's no guarantees we'll have time to work on it.

If you'd like to see JSON output added, feel free to leave a 👍 on this issue so we have a clearer picture of the impact!

@codykaup codykaup removed their assignment Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants