Skip to content

Commit ce07d18

Browse files
reporter option indentSize
1 parent a2cab8f commit ce07d18

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/cli/run-option-metadata.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const TYPES = (exports.types = {
4949
'sort',
5050
'watch'
5151
],
52-
number: ['retries', 'jobs', 'jsonStringifyWhitespace'],
52+
number: ['retries', 'jobs'],
5353
string: [
5454
'config',
5555
'fgrep',
@@ -78,7 +78,6 @@ exports.aliases = {
7878
ignore: ['exclude'],
7979
invert: ['i'],
8080
jobs: ['j'],
81-
jsonStringifyWhitespace: ['jsw'],
8281
'no-colors': ['C'],
8382
'node-option': ['n'],
8483
parallel: ['p'],

lib/reporters/json.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function JSONReporter(runner, options = {}) {
4545
var output;
4646

4747
if (options.reporterOption && options.reporterOption.output) {
48+
Base.consoleLog('JSON Options:', options.reporterOption);
4849
if (utils.isBrowser()) {
4950
throw createUnsupportedError('file output not supported in browser');
5051
}
@@ -78,7 +79,13 @@ function JSONReporter(runner, options = {}) {
7879

7980
runner.testResults = obj;
8081

81-
var json = JSON.stringify(obj, null, options.jsonStringifyWhitespace ?? 2);
82+
var optionsIndentSize;
83+
if (options.reporterOption && 'indentSize' in options.reporterOption) {
84+
optionsIndentSize = options.reporterOption.indentSize;
85+
}
86+
var indentSize = parseInt(optionsIndentSize, 10) || 2; // Cast string to int or default indentation
87+
88+
var json = JSON.stringify(obj, null, indentSize);
8289
if (output) {
8390
try {
8491
fs.mkdirSync(path.dirname(output), {recursive: true});

0 commit comments

Comments
 (0)