Skip to content

Commit

Permalink
fix: prevent error when "options" are not passed to checkForViolations (
Browse files Browse the repository at this point in the history
  • Loading branch information
appleJax authored Oct 23, 2020
1 parent e8d311a commit aeb840f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,22 @@ const createReport = violations => {
* @param options
* @returns {Promise<{error: *}|{error: *, results: {passes: *, violations: * }}>}
*/
const axeCheck = async (t, context, options={}) => {
const axeCheck = (t, context, options = { rules: {} }) => {
try {
// skipping the "document-title" rule as there is an issue with testcafe
// being unable to find the title of a page inside the <head> tag.
options = options["rules"]['document-title'] = {'enabled': false};
return await runAxe.with({ boundTestRun: t })(context, options);
} catch (e) {
return { error: e };
return runAxe.with({ boundTestRun: t })(context, options);
} catch (error) {
return Promise.resolve({ error });
}
};

const checkForViolations = async (t, context, options) => {
const { results } = await axeCheck(t, context, options);
const { error, results } = await axeCheck(t, context, options);

await t.expect(error).notOk();

await t.expect(results.violations.length === 0).ok(createReport(results.violations));
}

Expand Down

0 comments on commit aeb840f

Please sign in to comment.