Skip to content

Commit

Permalink
Merge pull request #264 from zaccolley/patch-1
Browse files Browse the repository at this point in the history
Improved error message if results are unexpected
  • Loading branch information
NickColley authored Mar 23, 2023
2 parents b72f1b7 + 49c8789 commit 07e1ef0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ describe("jest-axe", () => {
const matcherFunction = toHaveNoViolations.toHaveNoViolations;
expect(() => {
matcherFunction({});
}).toThrow("No violations found in aXe results object");
}).toThrow(
"Unexpected aXe results object. No violations property found.\nDid you change the `reporter` in your aXe configuration?"
);
});

it("returns pass as true when no violations are present", () => {
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ function filterViolations(violations, impactLevels) {
const toHaveNoViolations = {
toHaveNoViolations(results) {
if (typeof results.violations === "undefined") {
throw new Error("No violations found in aXe results object");
throw new Error(
"Unexpected aXe results object. No violations property found.\nDid you change the `reporter` in your aXe configuration?"
);
}

const violations = filterViolations(
Expand Down

0 comments on commit 07e1ef0

Please sign in to comment.