ember-a11y / ember-a11y-testing

A suite of accessibility tests that can be run within the Ember testing framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0.3: `axe.ember` is undefined

jonathanong opened this issue · comments

i have the following:

const axeOptions = window.axeOptions = {
  runOnly: {
    type: 'tag',
    values: ['wcag2a', 'wcag2aa'],
  },
  rules: {
    'color-contrast': { enabled: false },
  },
};

QUnit.moduleStart(() => {
  axe.ember.testOptions = axeOptions;
});

this broke in 0.3. axe.ember does not exist in 0.3. how would i fix this?

The axe.ember global was removed in 0.3 since the auto-run feature during tests was also removed, thus it no longer had a purpose. If you want to use this in the test environment, you can now use the a11yAudit helper and pass your options directly to that. See here for more info: https://github.com/ember-a11y/ember-a11y-testing#testing-usage

would a11yAudit(axeOptions); work?

apparently it does not.

{ type: 'error',
              text: '\'TypeError: axe.run arguments are invalid\\n    at normalizeRunParams (http://localhost:13336/assets/vendor.js:81697:19)\\n    at Object.axe.run (http://localhost:13336/assets/vendor.js:81745:16)\\n    at http://localhost:13336/assets/test-support.js:11317:11\\n    at initializePromise (http://localhost:13336/assets/vendor.js:78395:7)\\n    at new Promise (http://localhost:13336/assets/vendor.js:78883:33)\\n    at runA11yAudit (http://localhost:13336/assets/test-support.js:11316:24)\\n    at Class.<anonymous> (http://localhost:13336/assets/test-support.js:11337:25)\\n    at http://localhost:13336/assets/vendor.js:58213:19\\n    at isolate (http://localhost:13336/assets/vendor.js:59344:17)\\n    at http://localhost:13336/assets/vendor.js:59300:16\'\n' }

@jonathanong The audit helper takes axeOptions as its second argument (the first argument should either be a selector string or an HTML element).

In addition to @trentmwillis's link above, you can check out helper itself here.

We should likely update the helper to allow passing axeOptions as a single argument as well.

The above feature is now available in 0.4.0.