Skip to content

Commit

Permalink
feat(core/reporters/v1): Add failureSummary to incomplete results (#1972
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jayaddison authored and WilcoFiers committed Jan 13, 2020
1 parent 8a62649 commit c88883d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/core/reporters/v1.js
Expand Up @@ -9,11 +9,14 @@ axe.addReporter('v1', function(results, options, callback) {
}
var out = helpers.processAggregate(results, options);

out.violations.forEach(result =>
const addFailureSummaries = result => {
result.nodes.forEach(nodeResult => {
nodeResult.failureSummary = helpers.failureSummary(nodeResult);
})
);
});
};

out.incomplete.forEach(addFailureSummaries);
out.violations.forEach(addFailureSummaries);

callback({
...helpers.getEnvironmentData(),
Expand Down
41 changes: 38 additions & 3 deletions test/core/reporters/v1.js
Expand Up @@ -84,6 +84,34 @@ describe('reporters - v1', function() {
}
]
},
{
id: 'incomplete',
description: 'something yet more nifty',
tags: ['tag4'],
impact: 'monkeys',
result: 'failed',
passes: [],
violations: [],
incomplete: [
{
result: 'failed',
impact: 'monkeys',
none: [
{
data: 'foon',
impact: 'monkeys',
result: true
}
],
any: [],
all: [],
node: {
selector: ['foon'],
source: '<foon>telephone</foon>'
}
}
]
},
{
id: 'blinky',
description: 'something awesome',
Expand Down Expand Up @@ -232,16 +260,23 @@ describe('reporters - v1', function() {
});
it('should add the failure summary to the node data', function(done) {
var origFn = window.helpers.failureSummary;
window.helpers.failureSummary = function() {
return 'your foon is ringing';
window.helpers.failureSummary = function(nodeData) {
if (!nodeData || !nodeData.target) {
return;
}
return 'selector: ' + nodeData.target;
};
axe.run(optionsV1, function(err, results) {
assert.isNull(err);
assert.ok(results.violations[0].nodes);
assert.equal(results.violations[0].nodes.length, 1);
assert.equal(
results.violations[0].nodes[0].failureSummary,
'your foon is ringing'
'selector: q,r,pillock'
);
assert.equal(
results.incomplete[0].nodes[0].failureSummary,
'selector: foon'
);
window.helpers.failureSummary = origFn;
done();
Expand Down

0 comments on commit c88883d

Please sign in to comment.