Skip to content

Commit

Permalink
fix(dom-selectors): byRole typings (#591)
Browse files Browse the repository at this point in the history
Add proper typings to `byRole` to get role autocomplete
  • Loading branch information
HafizAhmedMoon committed Nov 2, 2022
1 parent 7ac6dbe commit e537f64
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion projects/spectator/src/lib/dom-selectors.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {
Matcher,
MatcherFunction,
MatcherOptions,
NormalizerFn,
SelectorMatcherOptions,
queries as DOMQueries,
getDefaultNormalizer,
ByRoleOptions
} from '@testing-library/dom';
import { ARIARole } from 'aria-query';

interface MandatorySelectorMatchingOptions extends MatcherOptions {
selector: SelectorMatcherOptions['selector'];
Expand Down Expand Up @@ -66,5 +68,5 @@ export const byTestId: DOMSelectorFactory = (matcher, options) => new DOMSelecto
export const byValue: DOMSelectorFactory = (matcher, options) =>
new DOMSelector(el => DOMQueries.queryAllByDisplayValue(el, matcher, options));

export const byRole: DOMSelectorFactory<ByRoleOptions> = (matcher, options) =>
export const byRole = (matcher: ARIARole | MatcherFunction | Omit<string, ARIARole>, options?: ByRoleOptions): DOMSelector =>
new DOMSelector(el => DOMQueries.queryAllByRole(el, matcher, options));

0 comments on commit e537f64

Please sign in to comment.