diff --git a/lib/reporters/json.js b/lib/reporters/json.js index 6194d8747d..2ea4ed913b 100644 --- a/lib/reporters/json.js +++ b/lib/reporters/json.js @@ -78,7 +78,16 @@ function JSONReporter(runner, options = {}) { runner.testResults = obj; - var json = JSON.stringify(obj, null, 2); + var optionsIndentSize; + if (options.reporterOption && 'indentSize' in options.reporterOption) { + optionsIndentSize = options.reporterOption.indentSize; + } else { + optionsIndentSize = 2; // Default Indentation size + } + + var indentSize = parseInt(optionsIndentSize, 10); // Cast string to int + + var json = JSON.stringify(obj, null, indentSize); if (output) { try { fs.mkdirSync(path.dirname(output), {recursive: true});