-
Notifications
You must be signed in to change notification settings - Fork 53
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
simplify conditional audit running even further #208
Comments
Hey @fivetanley, thanks for the detailed write-up! I think it's useful to step back and discuss the direction we're trying to take this addon. Hopefully that will help mitigate some of your concerns WRT the current APIs. I wrote up an issue that discusses the direction we're trying to move in. In addition, there's a second issue that describes a new API that's been added: The simplification of the qunit APIs in This addon mimics those helpers in that the
The idea with the With the deprecation of the Additionally, the reason we didn't built the conditional Based on the above, my sense is that we should not add the I think the idea of having a CI flag is a reasonable one. I'd love to chat with you more to see how this fits into the broad strategy. cc/ @rwjblue for anything I maybe have miscommunicated or left out. |
I think @scalvert addressed most/all of your original points, but I did want to call out one specific thing here:
The thing is, we are absolutely trying to encourage folks to remove the explicit
Wouldn't it be nice to not have to? Your tests can look like: await visit('/');
await click('.selector');
await fillIn('.text-box', 'name'); And you still have the exact same guarantee as you have today, just less lines of code, less conceptual overhead to developers, etc. tldr; these changes are geared towards making test authors "fall into the pit of success"... |
Thanks for the extremely detailed responses @rwjblue @scalvert. I think I'm in agreement in all points. Thanks for walking me through the vision, I am excited every time I interact with any of the Ember projects; it's good to be in an OSS community collaborating and making a lot of progress on bringing the community and their users into a more accessible world. :) After reading both of these responses, I think this issue can be closed. Perhaps the only carry over issue (to create as a new issue?) would be to have some way to provide dynamic configuration for enabling/disabling audits globally (CI for example, but we could allow people to define this based on any computation that provides a boolean value). What do you think? |
@fivetanley - The current design is that the app would supply a function that is effectively "should audit" when they call So to run on roughly 10% of tests (randomly if you use a QUnit seed, but prints info on deterministically re-running), you would do something like: // tests/test-helper.js
// ...snip...
let invocationCounter: number = 0;
setupGlobalA11yHooks((_helperName, label) => {
invocationCounter++;
return invocationCounter % 10 === 0;
}) Does that do the trick, or are you asking for a slightly different thing? |
That's great. Thanks! |
Sounds good. Feel free to open an issue related to controlling the execution via a CI env var. Thanks! |
Introduction
In #203, the documentation was updated to recommend using the following code:
It's great to have new primitives, but this code is really verbose and it can be easy to wrap
await a11yAudit()
in an if statement from time to time, leading to flaky or inconsistent builds, which might encourage people to remove or disable (and forget to investigate and re-enable)a11yAudit()
.For our app, we use eslint-plugin-ember-a11y-testing and its autofix features to ensure every call to
visit
/render
/etc
is followed byawait a11yAudit()
. This already adds a fair amount of noise to the tests as is:With the out-of-the-box ember experience, the tests would now look like:
This makes the tests much larger than they need to be. While we could add a custom function (as noted in the updated README, and the [eslint plugin supports this]), it feels like this will be fairly common for folks. The out-of-the-box experience feels difficult to maintain consistency.
Since Ember is about providing an opinionated default to ensure consistency between apps and a great out of the box experience, I'd like to propose the following.
Remove need for custom if statements by having a11yAudit check shouldForceAudit
Rather than having lots of
if
statement which adds noise to tests,a11yAudit
should callshouldForceAudit
internally. That way, all tests will look like:The implementation would look very similar to the existing implementation, just wrapped in an
if
statement:What I'd propose is a couple tweaks to the new APIs:
enableAudit()
anddisableAudit()
- modify the module state fora11yAudit()
usingsetEnableA11yAudit
under the hood. This will enable conditional disabling/enabling of audits and some cool new linting features to help developers (which are mentioned below)shouldForceAudit()
, but maybe rename toauditsEnabled()
to matchenableAudit
change aboveenableAudit()
anddisableAudit()
would not modify the urlParameters as the existingsetEnableA11yAudit
helpers does. ItThis enables a few key things:
if
statement, we can keep the ESLint plugin mentioned above the samebeforeEach
hook to keep state clean between testsEnables better editor/linting integrations
This isn't something I expect to be done as part of this issue in this project, rather something I'd volunteer to do with the new APIs in eslint-plugin-ember-a11y-testing.
This would also allow me to improve the experience of eslint-plugin-ember-a11y-testing. We could add some new lint rules:
Today's existing behavior with the lint plugin is this:
The fixed code (which can be autofixed) looks like this:
Some new additions to the rule could take advantage of
enableAudit
anddisableAudit
to help minimize state bugs between tests. For example, it could take whetherenableAudit
ordisableAudit
was called around the@ember/test-helper
when deciding whether or not to log an error:The ESLint plugin could also require that
enableAudit()
was called afterdisableAudit()
so that other@ember/test-helper
calls aren't accidentally missed by the audit:Expose UI for developers through QUnit's urlconfig
QUnit (the default for ember apps) provides some functionality in the UI to expose UI for enabling/disabling settings. Ember A11y Testing could (if the app is using QUnit), use QUnit.config.urlconfig to expose a checkbox to work with the query param for enabling/disabling tests. This would be a nicer out of box experience.
Update documentation to include value from config
In CI environments, it's common to use environment variables to determine whether or not do something. Right now it's not clear how to do that other than modifying the ember test command to include the URL query parameter. The documentation could be updated with the following example for
tests/test-helper
with the new APIs:I'm happy to make PRs as this seems like an easy change to make before a new stable version is declared. Let me know what you think! Thanks.
The text was updated successfully, but these errors were encountered: