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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion lib/cli/run-option-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const TYPES = (exports.types = {
'sort',
'watch'
],
number: ['retries', 'jobs'],
number: ['retries', 'jobs', 'jsonStringifyWhitespace'],
string: [
'config',
'fgrep',
Expand Down Expand Up @@ -78,6 +78,7 @@ exports.aliases = {
ignore: ['exclude'],
invert: ['i'],
jobs: ['j'],
jsonStringifyWhitespace: ['jsw'],
'no-colors': ['C'],
'node-option': ['n'],
parallel: ['p'],
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/json.js
CheadleCheadle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function JSONReporter(runner, options = {}) {

runner.testResults = obj;

var json = JSON.stringify(obj, null, 2);
var json = JSON.stringify(obj, null, options.jsonStringifyWhitespace ?? 2);
if (output) {
try {
fs.mkdirSync(path.dirname(output), {recursive: true});
Expand Down
Loading