Skip to content

Commit 07e1ef0

Browse files
authored
Merge pull request #264 from zaccolley/patch-1
Improved error message if results are unexpected
2 parents b72f1b7 + 49c8789 commit 07e1ef0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

__tests__/index.test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ describe("jest-axe", () => {
218218
const matcherFunction = toHaveNoViolations.toHaveNoViolations;
219219
expect(() => {
220220
matcherFunction({});
221-
}).toThrow("No violations found in aXe results object");
221+
}).toThrow(
222+
"Unexpected aXe results object. No violations property found.\nDid you change the `reporter` in your aXe configuration?"
223+
);
222224
});
223225

224226
it("returns pass as true when no violations are present", () => {

index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ function filterViolations(violations, impactLevels) {
123123
const toHaveNoViolations = {
124124
toHaveNoViolations(results) {
125125
if (typeof results.violations === "undefined") {
126-
throw new Error("No violations found in aXe results object");
126+
throw new Error(
127+
"Unexpected aXe results object. No violations property found.\nDid you change the `reporter` in your aXe configuration?"
128+
);
127129
}
128130

129131
const violations = filterViolations(

0 commit comments

Comments
 (0)