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

feat: added optional jsw format to json reporter #5017

Closed

Conversation

CheadleCheadle
Copy link

@CheadleCheadle CheadleCheadle commented Oct 17, 2023

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions.

Description of the Change

Added an optional CLI argument ('jsw' or 'jsonStringifyWhitespace') that allows for the user to set the whitespace of the JSON reporter. If it isn't provided it defaults to the current value (2).

This change allows for more customization of the JSON output!
Closes #4889

Alternate Designs

An alternative approach might involve using a boolean CLI argument to toggle the JSON reporter and remove whitespace. However, a more precise level of customization can be achieved by using a CLI argument to control the amount of whitespace instead.

Why should this be in core?

It's a relatively simple change that simplifies the parsing of the JSON output."

Benefits

This feature would prove valuable when parsing JSON test results. For example, Splunk mandates JSON formatting with no whitespace, and having the option to generate whitespace-free JSON would enable Splunk to directly use the data without additional processing.

Possible Drawbacks

There shouldn't be any drawbacks to making this modification. It allows for further customization but is kept default if not specified.

Applicable issues

N/A

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 17, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@JoshuaKGoldberg JoshuaKGoldberg added status: waiting for author waiting on response from OP - more information needed semver-minor implementation requires increase of "minor" version number; "features" labels Mar 4, 2024
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as waiting for changes per #4889 (comment).

@JoshuaKGoldberg JoshuaKGoldberg changed the title added optional jsw format to json reporter feat: added optional jsw format to json reporter Mar 4, 2024
@CheadleCheadle
Copy link
Author

CheadleCheadle commented Mar 5, 2024

I addressed the changes requested in #4889 (comment).

Instead of jsonStringifyWhiteSpace, I went with indentSize. It is not only shorter and easier to type, but clearer in what it is used for!

@JoshuaKGoldberg JoshuaKGoldberg added status: in triage a maintainer should (re-)triage (review) this issue and removed status: waiting for author waiting on response from OP - more information needed labels Mar 5, 2024
@coveralls
Copy link

Coverage Status

coverage: 94.337% (-0.02%) from 94.359%
when pulling 8d16512 on CheadleCheadle:optional-reporter-format
into 3735873 on mochajs:master.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Progress! 🚀

lib/reporters/json.js Outdated Show resolved Hide resolved
lib/reporters/json.js Outdated Show resolved Hide resolved
@JoshuaKGoldberg JoshuaKGoldberg added status: waiting for author waiting on response from OP - more information needed and removed status: in triage a maintainer should (re-)triage (review) this issue labels Jul 2, 2024
@JoshuaKGoldberg JoshuaKGoldberg removed the status: waiting for author waiting on response from OP - more information needed label Aug 6, 2024
bin/mocha.js Outdated Show resolved Hide resolved
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting there, but I think we might have missed each other on the reporter option name & usage?

test/reporters/json.spec.js Outdated Show resolved Hide resolved
lib/reporters/json.js Show resolved Hide resolved
lib/reporters/json.js Outdated Show resolved Hide resolved
@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author waiting on response from OP - more information needed label Aug 6, 2024
@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Oct 8, 2024

👋 Ping @CheadleCheadle, is this still something you have energy & time for?

I'm waiting to be explicitly re-requested for review. Please let me know if I should go ahead and re-review. 🙂

@JoshuaKGoldberg JoshuaKGoldberg added the stale this has been inactive for a while... label Oct 8, 2024
@JoshuaKGoldberg
Copy link
Member

Closing out to free up the backing issue. @CheadleCheadle if you end up seeing this and having time again, no worries, feel free to re-open the PR or send a new one.

If anybody else sees this message and there isn't a new PR, feel free to send one yourself. Just make sure to add a co-author attribution if it takes code from this PR.

Cheers all! 🤎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor implementation requires increase of "minor" version number; "features" stale this has been inactive for a while... status: waiting for author waiting on response from OP - more information needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Feature: JSON reporter with optional formatting
3 participants