Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide conditional usage for 'setupMiddlewareReporter' #267

Merged
merged 6 commits into from
Jun 18, 2021

Conversation

drewlee
Copy link
Contributor

@drewlee drewlee commented Jun 4, 2021

Base implementation to address #266.

The basic idea is to output the environment variables in addon-test-support/cli-options.ts. If either one is specified, their corresponding value is overridden at build-time to true, and thus accessible from the browser/headless-browser environment.

This also provides a new useMiddlewareReporter API, to conditionally invoke setupMiddlewareReporter.

import { useMiddlewareReporter, setupMiddlewareReporter } from 'ember-a11y-testing/test-support';

if (useMiddlewareReporter()) {
  setupMiddlewareReporter();
}

Either one of these invocations will make useMiddlewareReporter return true, otherwise it's false:

ember test --query "enableA11yMiddlewareReporter=true"
ENABLE_A11Y_MIDDLEWARE_REPORTER=true ember test

Either one of these invocations will force a11y audit:

ember test --query "enableA11yAudit=true"
ENABLE_A11Y_AUDIT=true ember test

Ran this implementation with several apps to verify builds and tests work as expected.

@drewlee drewlee force-pushed the drewlee/options branch from 9e1a9dd to d905a47 Compare June 4, 2021 18:04
@drewlee drewlee requested a review from scalvert June 4, 2021 19:17
@scalvert
Copy link
Contributor

Is this still a draft or do you think it's ready, @drewlee?

@drewlee
Copy link
Contributor Author

drewlee commented Jun 11, 2021

If you don't see any glaring issues, then I can pull this out of draft @scalvert. These changes are pretty stable, so I will go ahead in the interest of collab.

@drewlee drewlee marked this pull request as ready for review June 11, 2021 15:43
@drewlee drewlee changed the title [WIP] Provide conditional usage for 'setupMiddlewareReporter' Provide conditional usage for 'setupMiddlewareReporter' Jun 11, 2021
addon-test-support/index.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,10 @@
import { ENABLE_A11Y_MIDDLEWARE_REPORTER } from './cli-options';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we rename this to useMiddlewareReporter, should we also rename this const to USE_A11Y_MIDDLEWARE_REPORTER?

Copy link
Contributor Author

@drewlee drewlee Jun 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep it as is, so it's consistent with ENABLE_A11Y_AUDIT and enableA11yAudit=true.

@drewlee drewlee requested a review from scalvert June 17, 2021 17:20
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
addon-test-support/should-force-audit.ts Outdated Show resolved Hide resolved
@scalvert
Copy link
Contributor

Overall this looks good. Thanks, @drewlee!

Andrew A Lee and others added 4 commits June 18, 2021 09:27
Co-authored-by: Steve Calvert <steve.calvert@gmail.com>
Co-authored-by: Steve Calvert <steve.calvert@gmail.com>
Co-authored-by: Steve Calvert <steve.calvert@gmail.com>
Co-authored-by: Steve Calvert <steve.calvert@gmail.com>
@drewlee drewlee requested a review from scalvert June 18, 2021 16:39
@drewlee drewlee merged commit 3947e4e into master Jun 18, 2021
@drewlee drewlee deleted the drewlee/options branch December 3, 2022 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants