GoogleChrome / accessibility-developer-tools

This is a library of accessibility-related testing and utility code.
Apache License 2.0
2.28k stars 362 forks source link

Provide assertAccessible(element) for closure unit tests #76

Open ewinslow opened 10 years ago

ewinslow commented 10 years ago

I apologize for not having the time to submit a proper pull request, but I wanted to get this recorded because it's pretty straightforward and I'd like other projects to be able to take advantage of this:

/**
 * Asserts that the given element and its descendants pass a suite of
 * accessibility checks.
 *
 * @param {!Element} element
 */
function assertAccessible(element) {  
  var auditConfig = new axs.AuditConfiguration();
  auditConfig.scope = element;

  var results = axs.Audit.run(auditConfig);
  var auditResults = axs.Audit.auditResults(results);

  assert(auditResults.toString(), auditResults.numErrors() == 0);
}
alice commented 9 years ago

This is great, but I'm unsure where it should live in this project. I'd love to hear from someone using closure testing (e.g. @ewinslow if still applicable!) where it would be useful.

ewinslow commented 9 years ago

I was thinking a new directory like src/testing/closure.js Then you could also have src/testing/jasmine.js for jasmine, etc.

@ckundo recommended we make separate repos for the axs-tools-to-testing-library glue code. One per library. I'm leaning slightly against that since separate repos feels like it would incur a little extra overhead than necessary, given the size of the code we're talking about.

ckundo commented 9 years ago

@ewinslow yes, I agree with you now. It'd be less complicated than pointing to multiple repos. We're including the test runner in this repo, it makes sense that plugins would live here too.

ewinslow commented 9 years ago

Great. It'll be nice to have all those helpers under one roof...