Display axe version on summary page (#3950)
This commit is contained in:
parent
8a07e1194a
commit
e7af25ac2c
|
|
@ -2,6 +2,8 @@ import { resolve } from 'node:path';
|
|||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import intel from 'intel';
|
||||
import axe from 'axe-core';
|
||||
const { version: axeVersion } = axe;
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
const log = intel.getLogger('sitespeedio.plugin.axe');
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
|
@ -15,7 +17,7 @@ export default class AxePlugin extends SitespeedioPlugin {
|
|||
this.options = options;
|
||||
this.make = context.messageMaker('axe').make;
|
||||
this.pug = readFileSync(resolve(__dirname, 'pug', 'index.pug'), 'utf8');
|
||||
log.info('Axe plugin activated');
|
||||
log.info(`Axe version %s plugin activated`, axeVersion);
|
||||
}
|
||||
|
||||
processMessage(message, queue) {
|
||||
|
|
@ -35,7 +37,7 @@ export default class AxePlugin extends SitespeedioPlugin {
|
|||
|
||||
case 'sitespeedio.setup': {
|
||||
// Tell other plugins that axe will run
|
||||
queue.postMessage(make('axe.setup'));
|
||||
queue.postMessage(make('axe.setup', { version: axeVersion }));
|
||||
|
||||
// Add the HTML pugs
|
||||
queue.postMessage(
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
- const axe = pageInfo.data.axe.run ? pageInfo.data.axe.run : pageInfo.data.axe.pageSummary
|
||||
|
||||
|
||||
a
|
||||
h2 Axe
|
||||
p Axe is an accessibility testing engine for websites and other HTML-based user interfaces. Read more about
|
||||
a(href='https://github.com/dequelabs/axe-core') axe-core
|
||||
| . #{axe.testEngine ? 'Tested using ' + axe.testEngine.name + ' ' + axe.testEngine.version + '.' : ''}
|
||||
|
||||
p Axe is an accessibility testing engine for websites and other HTML-based user interfaces. Tested using #{axe.testEngine.name} version #{axe.testEngine.version}. Read more about
|
||||
a(href='https://github.com/dequelabs/axe-core') axe-core
|
||||
| .
|
||||
|
||||
if pageInfo.data.axe.run
|
||||
h3 Violations
|
||||
|
|
|
|||
|
|
@ -123,6 +123,11 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
|
|||
_merge(options, message.data);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'axe.setup': {
|
||||
this.axeVersion = message.data.version;
|
||||
break;
|
||||
}
|
||||
// Andother plugin got JavaScript that they want to run in Browsertime
|
||||
case 'browsertime.scripts': {
|
||||
if (message.data.category && message.data.scripts) {
|
||||
|
|
@ -540,14 +545,12 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
|
|||
|
||||
// Post the result on the queue so other plugins can use it
|
||||
if (this.useAxe) {
|
||||
super.sendMessage(
|
||||
'axe.pageSummary',
|
||||
axeAggregatorPerURL.summarizeStats(),
|
||||
{
|
||||
url,
|
||||
group
|
||||
}
|
||||
);
|
||||
let stats = axeAggregatorPerURL.summarizeStats();
|
||||
stats.testEngine = { version: this.axeVersion, name: 'axe-core' };
|
||||
super.sendMessage('axe.pageSummary', stats, {
|
||||
url,
|
||||
group
|
||||
});
|
||||
}
|
||||
|
||||
// Check for errors. Browsertime errors is an array of all iterations
|
||||
|
|
|
|||
Loading…
Reference in New Issue