Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try using axe disableFrame function to resolve Axe end to end test error #26535

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions packages/e2e-tests/config/setup-test-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,23 @@ async function runAxeTestsForBlockEditor() {
'aria-hidden-focus',
'aria-input-field-name',
'aria-valid-attr-value',
'button-name',
'color-contrast',
'dlitem',
// 'button-name',
// 'color-contrast',
// 'dlitem',
'duplicate-id',
'label',
'landmark-one-main',
// 'label',
// 'landmark-one-main',
'link-name',
'listitem',
'region',
// 'listitem',
// 'region',
Copy link
Contributor

@Addison-Stavlo Addison-Stavlo Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have missed it in the discussion. Was there a reason we are commenting out a handful of the disabled rules?

nevermind i see it in comment - #26535 (comment) - is the idea to re-enable (or re-disable 🤣 ) these before merging?

'aria-required-children',
'aria-required-parent',
'frame-title',
],
disabledFrames: [
// Ignore block previews.
'[aria-hidden="true"]',
talldan marked this conversation as resolved.
Show resolved Hide resolved
],
exclude: [
// Ignores elements created by metaboxes.
'.edit-post-layout__metaboxes',
Expand Down
29 changes: 17 additions & 12 deletions packages/jest-puppeteer-axe/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,24 @@ function formatViolations( violations ) {
*
* @see https://github.com/dequelabs/axe-core-npm/tree/develop/packages/puppeteer
*
* @param {Page} page Puppeteer's page instance.
* @param {?Object} params Optional params that allow better control over Axe API.
* @param {?string|Array} params.include CSS selector(s) to add to the list of elements
* to include in analysis.
* @param {?string|Array} params.exclude CSS selector(s) to add to the list of elements
* to exclude from analysis.
* @param {?Array} params.disabledRules The list of Axe rules to skip from verification.
* @param {?RunOptions} params.options A flexible way to configure how Axe run operates,
* see https://github.com/dequelabs/axe-core/blob/master/doc/API.md#options-parameter.
* @param {?Spec} params.config Axe configuration object,
* see https://github.com/dequelabs/axe-core/blob/master/doc/API.md#api-name-axeconfigure.
* @param {Page} page Puppeteer's page instance.
* @param {?Object} params Optional params that allow better control over Axe API.
* @param {?string|Array} params.include CSS selector(s) to add to the list of elements
* to include in analysis.
* @param {?string|Array} params.exclude CSS selector(s) to add to the list of elements
* to exclude from analysis.
* @param {?Array} params.disabledRules The list of Axe rules to skip from verification.
* @param {?Array} params.disabledFrames An array of selectors for iframes that are disabled in axe tests
* @param {?RunOptions} params.options A flexible way to configure how Axe run operates,
* see https://github.com/dequelabs/axe-core/blob/master/doc/API.md#options-parameter.
* @param {?Spec} params.config Axe configuration object,
* see https://github.com/dequelabs/axe-core/blob/master/doc/API.md#api-name-axeconfigure.
*
* @return {Object} A matcher object with two keys `pass` and `message`.
*/
async function toPassAxeTests(
page,
{ include, exclude, disabledRules, options, config } = {}
{ include, exclude, disabledRules, disabledFrames, options, config } = {}
) {
const axe = new AxePuppeteer( page );

Expand All @@ -98,6 +99,10 @@ async function toPassAxeTests(
axe.disableRules( disabledRules );
}

if ( disabledFrames ) {
disabledFrames.forEach( ( frame ) => axe.disableFrame( frame ) );
}

if ( config ) {
axe.configure( config );
}
Expand Down