NickColley / jest-axe

Custom Jest matcher for aXe for testing accessibility ♿️🃏
MIT License
1.06k stars 54 forks source link

[Feature Request] Add ability to specify metadata when adding customized checks & rules #278

Closed hoaannguyen07 closed 8 months ago

hoaannguyen07 commented 12 months ago

When defining customized checks and rules, I cannot define metadata for checks (includes impact & messages for pass/fail) and rules (includes description, help, etc.), which can be defined when using straight from the 'axe-core' package. These messages are very helpful for debugging and would be a great help to developers.

Jest-Core's Check Interface:

interface Check {
  id: string;
  evaluate: Function | string;
  after?: Function | string;
  options?: any;
  matches?: string;
  enabled?: boolean;
}

Axe-Core's Check Interface:

interface Check {
    id: string;
    evaluate?: Function | string;
    after?: Function | string;
    options?: any;
    matches?: string;
    enabled?: boolean;
    metadata?: {
      impact?: ImpactValue;
      messages?: CheckMessages;
    };
}

Jest-Core's Rule Interface:

interface Rule {
  id: string;
  selector?: string;
  excludeHidden?: boolean;
  enabled?: boolean;
  pageLevel?: boolean;
  any?: string[];
  all?: string[];
  none?: string[];
  tags?: string[];
  matches?: string;
}

Axe-Core's Rule Interface:

interface Rule {
    id: string;
    selector?: string;
    impact?: ImpactValue;
    excludeHidden?: boolean;
    enabled?: boolean;
    pageLevel?: boolean;
    any?: string[];
    all?: string[];
    none?: string[];
    tags?: string[];
    matches?: string;
    reviewOnFail?: boolean;
    metadata?: Omit<RuleMetadata, 'ruleId'>;
}
interface RuleMetadata {
    ruleId: string;
    description: string;
    help: string;
    helpUrl: string;
    tags: string[];
    actIds?: string[];
}
tvalerius-chwy commented 9 months ago

Same issue here. Without the custom messaging, the output creates a less than helpful developer experience. image

NickColley commented 8 months ago

There are no restrictions in what you can pass to the underlying axe-core library in this package, I think your issue is one with the third-party Typescript interfaces that I do not maintain so you should find where that is and contribute there.