@axe-core/cli
Version:
A CLI for accessibility testing using axe-core
54 lines • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
exports.default = ({ silentMode, timer, cliReporter, verbose }) => {
return {
startTimer: (message) => {
console.time(message);
},
endTimer: (message) => {
console.timeEnd(message);
},
waitingMessage: (loadDelayTime) => {
console.log('Waiting for ' + loadDelayTime + ' milliseconds after page loads...');
},
onTestStart: (url) => {
if (silentMode) {
return;
}
console.log((0, utils_1.bold)('\nTesting ' + (0, utils_1.link)(url)) +
' ... please wait, this may take a minute.');
if (timer) {
console.time('Total test time');
}
},
onTestComplete: (results) => {
const { violations, testEngine, testEnvironment, testRunner } = results;
/* istanbul ignore if */
if (violations.length === 0) {
cliReporter((0, utils_1.green)(' 0 violations found!'));
return;
}
const issueCount = violations.reduce((count, violation) => {
cliReporter('\n' +
(0, utils_1.error)(' Violation of %j with %d occurrences!\n') +
' %s. Correct invalid elements at:\n' +
violation.nodes
.map(node => ' - ' + (0, utils_1.selectorToString)(node.target) + '\n')
.join('') +
' For details, see: %s', violation.id, violation.nodes.length, violation.description, (0, utils_1.link)(violation.helpUrl.split('?')[0]));
return count + violation.nodes.length;
}, 0);
cliReporter((0, utils_1.error)('\n%d Accessibility issues detected.'), issueCount);
if (verbose) {
const metadata = {
'Test Runner': testRunner,
'Test Engine': testEngine,
'Test Environment': testEnvironment
};
cliReporter(`\n${JSON.stringify(metadata, null, 2)}`);
}
}
};
};
//# sourceMappingURL=events.js.map