helen-dikareva / axe-testcafe

The helper for using Axe in TestCafe tests
36 stars 13 forks source link

Updates and new features #3

Closed dwightjack closed 5 years ago

dwightjack commented 6 years ago

I really like the idea to be able to use axe-core with testcafe. So I've picked up this plugin and made some updates and changes:

1) Set the minimum node version requirement to >=8.9.0. Testcafe uses async/await so it makes sense. 2) Updated the language to es2015+. That is just to leverage some es2015 syntactic sugar. 3) Instead of throwing on error, now axeCheck returns an object with error (populated whenever an error occurs) and violations (axe-core reported violations) properties. That way the user can use violations in a t.expect call. 4) Extracted the report generation logic to its own function. That makes possible to opt for a custom reporter instead of the default one.

dwightjack commented 6 years ago

Forgot to mention: I addressed the same issue solved in #2 by placing axe-core in the peerDependencies list.

justrhysism commented 6 years ago

Until this PR gets approved, I'm going to have to use the source branch directly.

justrhysism commented 6 years ago

Typings:

declare module 'axe-testcafe' {
  import { ElementContext, RunOnly, AxeResults, Result } from 'axe-core';
  import 'testcafe';

  export function axeCheck(
    t: TestController,
    context?: ElementContext,
    options?: {
      runOnly?: RunOnly;
      rules?: Object;
      iframes?: Boolean;
      elementRef?: Boolean;
      selectors?: Boolean;
    }
  ): Promise<AxeResults>;

  export function createReport(violations: Result[]): string;
}
JoshuaKGoldberg commented 5 years ago

Ping @helen-dikareva, would you / testcafe like some support maintaining this plugin?

dwightjack commented 5 years ago

@helen-dikareva Thanks for your review. 😃

Right now there's a conflict in the package.json. 😢

jrparish commented 5 years ago

This is great, thanks for your work!

Can we also get the typings added as mentioned in this comment? https://github.com/helen-dikareva/axe-testcafe/pull/3#issuecomment-430876982

It would be great to get this in so we can start using an updated axe-core.

dwightjack commented 5 years ago

@jrparish I added an index.d.ts file with the type declarations referenced it ona typings property in the package.json.

I hope I got it right right. Let me know if there something I missed.

jrparish commented 5 years ago

Typings look good.

There seems to be an issue with the package.json after the latest merge with master though. Might need to update the peer dependency to be: "axe-core": ">=2.2.3 <4"

jrparish commented 5 years ago

@dwightjack - are you able to fix the peer dependency in package.json?

dwightjack commented 5 years ago

@jrparish sure! I'm traveling until the 5th so I won't be able to work on it right away.

dwightjack commented 5 years ago

@jrparish Sorry for the delay!

Fixed package.json and updated the peer dependency.

justrhysism commented 5 years ago

So now this has been merged, is it possible to get a release?