diff --git a/doc/API.md b/doc/API.md index 16aae332a9..ba0a207f6a 100644 --- a/doc/API.md +++ b/doc/API.md @@ -440,13 +440,14 @@ Additionally, there are a number or properties that allow configuration of diffe 6. Only process certain types of results - The `resultTypes` option can be used to limit the result types that aXe will process, aggregate, and send to the reporter. This can be useful for improving performance on very large or complicated pages when you are only interested in certain types of results. + The `resultTypes` option can be used to limit the result types that aXe will process, aggregate, and send to the reporter. This can be useful for improving performance on very large or complicated pages when you are only interested in certain types of results. The option will return 1 result of each type if that rule has at least one of that type of result instead of returning all of that type of result. The caller can use this information to inform the user of the existence of that type of result if appropriate. + ```javascript { resultTypes: ['violations', 'incomplete', 'inapplicable'] } ``` - This example will only process the specified result types: "violations", "incomplete", and "inapplicable". Notably, it will not process "passes". On a series of extremely large pages, this could improve performance considerably. + This example will only process the specified result types: "violations", "incomplete", and "inapplicable". Notably, it will only process the first pass for each rule that has a pass. On a series of extremely large pages, this could improve performance considerably. ##### Callback Parameter diff --git a/lib/core/reporters/helpers/process-aggregate.js b/lib/core/reporters/helpers/process-aggregate.js index e124df749d..1f534fd3d3 100644 --- a/lib/core/reporters/helpers/process-aggregate.js +++ b/lib/core/reporters/helpers/process-aggregate.js @@ -59,8 +59,12 @@ helpers.processAggregate = function (results, options) { resultKeys.forEach(function (key) { if (options.resultTypes && !options.resultTypes.includes(key)) { - delete resultObject[key]; - return; + // If the user asks us to, truncate certain finding types to maximum one finding + (resultObject[key] || []).forEach(function (ruleResult) { + if (Array.isArray(ruleResult.nodes) && ruleResult.nodes.length > 0) { + ruleResult.nodes = [ruleResult.nodes[0]]; + } + }); } resultObject[key] = (resultObject[key] || []).map(function (ruleResult) { ruleResult = Object.assign({}, ruleResult); diff --git a/test/core/reporters/helpers/process-aggregate.js b/test/core/reporters/helpers/process-aggregate.js index 0a62c066a5..e8dcf5bab9 100644 --- a/test/core/reporters/helpers/process-aggregate.js +++ b/test/core/reporters/helpers/process-aggregate.js @@ -25,6 +25,25 @@ describe('helpers.processAggregate', function () { }], all: [], none: [] + }, { + result: 'passed', + node: { + element: document.createElement('div'), + selector: 'main > .thing', + source: '