Skip to content

Commit bcf4936

Browse files
patrickhulcejrolfs
authored andcommitted
fix: modify role options types to match upgraded @testing-library/dom
1 parent bf3968f commit bcf4936

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

lib/typedefs.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1-
import {Matcher, MatcherOptions, SelectorMatcherOptions, waitForOptions} from '@testing-library/dom'
1+
import {
2+
Matcher,
3+
MatcherOptions as MatcherOptions_,
4+
SelectorMatcherOptions as SelectorMatcherOptions_,
5+
waitForOptions,
6+
} from '@testing-library/dom'
27
import {ElementHandle as PlaywrightElementHandle} from 'playwright'
38

49
export type ElementHandle = PlaywrightElementHandle<SVGElement | HTMLElement>
510

611
type Element = ElementHandle
712

13+
type MatcherOptions = Omit<MatcherOptions_, 'normalizer'>
14+
type SelectorMatcherOptions = Omit<SelectorMatcherOptions_, 'normalizer'>
15+
16+
// tslint:disable-next-line
17+
interface RoleMatcherOptions extends MatcherOptions {
18+
name?: string | RegExp
19+
}
20+
21+
// tslint:disable-next-line
22+
interface SelectorRoleMatcherOptions extends SelectorMatcherOptions {
23+
name?: string | RegExp
24+
}
25+
826
interface IQueryMethods {
927
queryByPlaceholderText(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element | null>
1028
queryAllByPlaceholderText(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element[]>
@@ -108,20 +126,20 @@ interface IQueryMethods {
108126
waitForOpts?: waitForOptions,
109127
): Promise<Element[]>
110128

111-
queryByRole(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element | null>
112-
queryAllByRole(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element[]>
113-
getByRole(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element>
114-
getAllByRole(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element[]>
129+
queryByRole(el: Element, m: Matcher, opts?: RoleMatcherOptions): Promise<Element | null>
130+
queryAllByRole(el: Element, m: Matcher, opts?: RoleMatcherOptions): Promise<Element[]>
131+
getByRole(el: Element, m: Matcher, opts?: RoleMatcherOptions): Promise<Element>
132+
getAllByRole(el: Element, m: Matcher, opts?: RoleMatcherOptions): Promise<Element[]>
115133
findByRole(
116134
el: Element,
117135
m: Matcher,
118-
opts?: SelectorMatcherOptions,
136+
opts?: SelectorRoleMatcherOptions,
119137
waitForOpts?: waitForOptions,
120138
): Promise<Element>
121139
findAllByRole(
122140
el: Element,
123141
m: Matcher,
124-
opts?: SelectorMatcherOptions,
142+
opts?: SelectorRoleMatcherOptions,
125143
waitForOpts?: waitForOptions,
126144
): Promise<Element[]>
127145

@@ -150,8 +168,8 @@ export type BoundFunction<T> = T extends (
150168
options: infer Q,
151169
) => infer R
152170
? (text: P, options?: Q) => R
153-
: T extends (a1: any, text: infer P, options: infer Q, waitForElementOptions: infer W) => infer R
154-
? (text: P, options?: Q, waitForElementOptions?: W) => R
171+
: T extends (a1: any, text: infer P, options: infer Q, waitForOptions: infer W) => infer R
172+
? (text: P, options?: Q, waitForOptions?: W) => R
155173
: T extends (a1: any, text: infer P, options: infer Q) => infer R
156174
? (text: P, options?: Q) => R
157175
: never

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,9 +1161,9 @@
11611161
"@babel/plugin-transform-react-pure-annotations" "^7.10.1"
11621162

11631163
"@babel/runtime-corejs3@^7.10.2":
1164-
version "7.10.4"
1165-
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.10.4.tgz#f29fc1990307c4c57b10dbd6ce667b27159d9e0d"
1166-
integrity sha512-BFlgP2SoLO9HJX9WBwN67gHWMBhDX/eDz64Jajd6mR/UAUzqrNMm99d4qHnVaKscAElZoFiPv+JpR/Siud5lXw==
1164+
version "7.11.2"
1165+
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.11.2.tgz#02c3029743150188edeb66541195f54600278419"
1166+
integrity sha512-qh5IR+8VgFz83VBa6OkaET6uN/mJOhHONuy3m1sgF0CV6mXdPSEBdA7e1eUbVvyNtANjMbg22JUv71BaDXLY6A==
11671167
dependencies:
11681168
core-js-pure "^3.0.0"
11691169
regenerator-runtime "^0.13.4"

0 commit comments

Comments
 (0)