Skip to content

Commit

Permalink
Display axe version on summary page (#3950)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Aug 30, 2023
1 parent 8a07e11 commit e7af25a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
6 changes: 4 additions & 2 deletions lib/plugins/axe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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) {
Expand All @@ -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(
Expand Down
8 changes: 3 additions & 5 deletions lib/plugins/axe/pug/index.pug
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 11 additions & 8 deletions lib/plugins/browsertime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e7af25a

Please sign in to comment.