Skip to content

Commit

Permalink
Ensures context for current URL & route middleware reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
drewlee committed Aug 23, 2023
1 parent 2b479c9 commit 954629c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions addon-test-support/setup-middleware-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ export async function middlewareReporter(axeResults: AxeResults) {
return;
}

const context = getContext();

if (!currentTestResult) {
let { module, testName } = QUnit.config.current;
const context = getContext();
if (!context) {
throw new Error(
'You tried to run ember-a11y-testing without calling one of the `setupTest` helpers from `@ember/test-helpers`. Please make sure your test setup calls `setupTest()`, `setupRenderingTest()`, or `setupApplicationTest()`!'
Expand All @@ -102,8 +103,10 @@ export async function middlewareReporter(axeResults: AxeResults) {
currentRouteNames = new Set();
}

currentUrls!.add(currentURL());
currentRouteNames!.add(_getCurrentRouteName());
if (context) {
currentUrls!.add(currentURL());
currentRouteNames!.add(_getCurrentRouteName());
}

axeResults.violations.forEach((violation) => {
let rule = currentViolationsMap!.get(violation.id);
Expand Down

0 comments on commit 954629c

Please sign in to comment.