Skip to content

Commit 73b2bef

Browse files
author
Andrew A Lee
authored
Merge pull request #514 from ember-a11y/drewlee/curr-url
Ensures context for current URL & route middleware reporting
2 parents 2b479c9 + 954629c commit 73b2bef

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

addon-test-support/setup-middleware-reporter.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ export async function middlewareReporter(axeResults: AxeResults) {
7474
return;
7575
}
7676

77+
const context = getContext();
78+
7779
if (!currentTestResult) {
7880
let { module, testName } = QUnit.config.current;
79-
const context = getContext();
8081
if (!context) {
8182
throw new Error(
8283
'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()`!'
@@ -102,8 +103,10 @@ export async function middlewareReporter(axeResults: AxeResults) {
102103
currentRouteNames = new Set();
103104
}
104105

105-
currentUrls!.add(currentURL());
106-
currentRouteNames!.add(_getCurrentRouteName());
106+
if (context) {
107+
currentUrls!.add(currentURL());
108+
currentRouteNames!.add(_getCurrentRouteName());
109+
}
107110

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

0 commit comments

Comments
 (0)