chromatic-cli icon indicating copy to clipboard operation
chromatic-cli copied to clipboard

Feature Request: JSON output

Open petermikitsh opened this issue 3 years ago • 4 comments

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

petermikitsh avatar Feb 02 '22 01:02 petermikitsh

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?

kylesuss avatar Feb 05 '22 00:02 kylesuss

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

petermikitsh avatar Feb 08 '22 04:02 petermikitsh

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

tmeasday avatar Feb 08 '22 05:02 tmeasday