@lynx-js/react 0.106.5 → 0.107.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/package.json +15 -2
- package/refresh/.turbo/turbo-build.log +1 -1
- package/refresh/package.json +1 -1
- package/runtime/jsx-dev-runtime/index.d.ts +12 -0
- package/runtime/jsx-runtime/index.d.ts +12 -0
- package/runtime/lib/lifecycle/patch/commit.d.ts +7 -1
- package/runtime/lib/lifecycle/patch/commit.js +44 -38
- package/runtime/lib/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/lifecycle/patch/updateMainThread.js +6 -4
- package/runtime/lib/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/list.d.ts +13 -6
- package/runtime/lib/list.js.map +1 -1
- package/runtime/lib/lynx/calledByNative.js +2 -2
- package/runtime/lib/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/lynx/component.js +1 -1
- package/runtime/lib/lynx/component.js.map +1 -1
- package/runtime/lib/lynx/performance.d.ts +24 -14
- package/runtime/lib/lynx/performance.js +48 -23
- package/runtime/lib/lynx/performance.js.map +1 -1
- package/runtime/lib/lynx/runWithForce.d.ts +1 -0
- package/runtime/lib/lynx/runWithForce.js +45 -0
- package/runtime/lib/lynx/runWithForce.js.map +1 -0
- package/runtime/lib/lynx/tt.d.ts +2 -1
- package/runtime/lib/lynx/tt.js +27 -61
- package/runtime/lib/lynx/tt.js.map +1 -1
- package/runtime/lib/lynx.d.ts +1 -0
- package/runtime/lib/lynx.js +1 -0
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/src/lifecycle/patch/commit.ts +54 -41
- package/runtime/src/lifecycle/patch/updateMainThread.ts +6 -4
- package/runtime/src/list.ts +18 -10
- package/runtime/src/lynx/calledByNative.ts +2 -2
- package/runtime/src/lynx/component.ts +1 -1
- package/runtime/src/lynx/performance.ts +53 -22
- package/runtime/src/lynx/runWithForce.ts +52 -0
- package/runtime/src/lynx/tt.ts +42 -70
- package/runtime/src/lynx.ts +1 -0
- package/testing-library/README.md +70 -0
- package/testing-library/dist/env/vitest.js +548 -0
- package/testing-library/dist/index.d.ts +1504 -0
- package/testing-library/dist/index.js +12 -0
- package/testing-library/dist/pure.js +14729 -0
- package/testing-library/dist/pure.js.LICENSE.txt +17 -0
- package/testing-library/dist/vitest-global-setup.js +115 -0
- package/testing-library/dist/vitest.config.js +90 -0
- package/testing-library/types/entry.d.ts +257 -0
- package/testing-library/types/index.d.ts +15 -0
- package/testing-library/types/pure.d.ts +2 -0
- package/testing-library/types/vitest-config.d.ts +12 -0
- package/transform/dist/wasm.cjs +1 -1
- package/types/react.d.ts +31 -0
- package/LICENSE +0 -202
|
@@ -0,0 +1,1504 @@
|
|
|
1
|
+
import { ARIARole } from 'aria-query';
|
|
2
|
+
import { ComponentChild } from 'preact';
|
|
3
|
+
import { ComponentType } from 'preact';
|
|
4
|
+
import { JSDOM } from 'jsdom';
|
|
5
|
+
import { OptionsReceived } from 'pretty-format';
|
|
6
|
+
import * as prettyFormat from 'pretty-format';
|
|
7
|
+
|
|
8
|
+
export declare type AllByAttribute = (
|
|
9
|
+
attribute: string,
|
|
10
|
+
container: HTMLElement,
|
|
11
|
+
id: Matcher,
|
|
12
|
+
options?: MatcherOptions,
|
|
13
|
+
) => HTMLElement[]
|
|
14
|
+
|
|
15
|
+
export declare type AllByBoundAttribute<T extends HTMLElement = HTMLElement> = (
|
|
16
|
+
container: HTMLElement,
|
|
17
|
+
id: Matcher,
|
|
18
|
+
options?: MatcherOptions,
|
|
19
|
+
) => T[]
|
|
20
|
+
|
|
21
|
+
export declare type AllByRole<T extends HTMLElement = HTMLElement> = (
|
|
22
|
+
container: HTMLElement,
|
|
23
|
+
role: ByRoleMatcher,
|
|
24
|
+
options?: ByRoleOptions,
|
|
25
|
+
) => T[]
|
|
26
|
+
|
|
27
|
+
export declare type AllByText<T extends HTMLElement = HTMLElement> = (
|
|
28
|
+
container: HTMLElement,
|
|
29
|
+
id: Matcher,
|
|
30
|
+
options?: SelectorMatcherOptions,
|
|
31
|
+
) => T[]
|
|
32
|
+
|
|
33
|
+
export declare type BoundFunction<T> = T extends (
|
|
34
|
+
container: HTMLElement,
|
|
35
|
+
...args: infer P
|
|
36
|
+
) => infer R
|
|
37
|
+
? (...args: P) => R
|
|
38
|
+
: never
|
|
39
|
+
|
|
40
|
+
export declare type BoundFunctions<Q> = Q extends typeof queries
|
|
41
|
+
? {
|
|
42
|
+
getByLabelText<T extends HTMLElement = HTMLElement>(
|
|
43
|
+
...args: Parameters<BoundFunction<queries.GetByText<T>>>
|
|
44
|
+
): ReturnType<queries.GetByText<T>>
|
|
45
|
+
getAllByLabelText<T extends HTMLElement = HTMLElement>(
|
|
46
|
+
...args: Parameters<BoundFunction<queries.AllByText<T>>>
|
|
47
|
+
): ReturnType<queries.AllByText<T>>
|
|
48
|
+
queryByLabelText<T extends HTMLElement = HTMLElement>(
|
|
49
|
+
...args: Parameters<BoundFunction<queries.QueryByText<T>>>
|
|
50
|
+
): ReturnType<queries.QueryByText<T>>
|
|
51
|
+
queryAllByLabelText<T extends HTMLElement = HTMLElement>(
|
|
52
|
+
...args: Parameters<BoundFunction<queries.AllByText<T>>>
|
|
53
|
+
): ReturnType<queries.AllByText<T>>
|
|
54
|
+
findByLabelText<T extends HTMLElement = HTMLElement>(
|
|
55
|
+
...args: Parameters<BoundFunction<queries.FindByText<T>>>
|
|
56
|
+
): ReturnType<queries.FindByText<T>>
|
|
57
|
+
findAllByLabelText<T extends HTMLElement = HTMLElement>(
|
|
58
|
+
...args: Parameters<BoundFunction<queries.FindAllByText<T>>>
|
|
59
|
+
): ReturnType<queries.FindAllByText<T>>
|
|
60
|
+
getByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
61
|
+
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
|
|
62
|
+
): ReturnType<queries.GetByBoundAttribute<T>>
|
|
63
|
+
getAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
64
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
65
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
66
|
+
queryByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
67
|
+
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
|
|
68
|
+
): ReturnType<queries.QueryByBoundAttribute<T>>
|
|
69
|
+
queryAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
70
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
71
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
72
|
+
findByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
73
|
+
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
|
|
74
|
+
): ReturnType<queries.FindByBoundAttribute<T>>
|
|
75
|
+
findAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
76
|
+
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
|
|
77
|
+
): ReturnType<queries.FindAllByBoundAttribute<T>>
|
|
78
|
+
getByText<T extends HTMLElement = HTMLElement>(
|
|
79
|
+
...args: Parameters<BoundFunction<queries.GetByText<T>>>
|
|
80
|
+
): ReturnType<queries.GetByText<T>>
|
|
81
|
+
getAllByText<T extends HTMLElement = HTMLElement>(
|
|
82
|
+
...args: Parameters<BoundFunction<queries.AllByText<T>>>
|
|
83
|
+
): ReturnType<queries.AllByText<T>>
|
|
84
|
+
queryByText<T extends HTMLElement = HTMLElement>(
|
|
85
|
+
...args: Parameters<BoundFunction<queries.QueryByText<T>>>
|
|
86
|
+
): ReturnType<queries.QueryByText<T>>
|
|
87
|
+
queryAllByText<T extends HTMLElement = HTMLElement>(
|
|
88
|
+
...args: Parameters<BoundFunction<queries.AllByText<T>>>
|
|
89
|
+
): ReturnType<queries.AllByText<T>>
|
|
90
|
+
findByText<T extends HTMLElement = HTMLElement>(
|
|
91
|
+
...args: Parameters<BoundFunction<queries.FindByText<T>>>
|
|
92
|
+
): ReturnType<queries.FindByText<T>>
|
|
93
|
+
findAllByText<T extends HTMLElement = HTMLElement>(
|
|
94
|
+
...args: Parameters<BoundFunction<queries.FindAllByText<T>>>
|
|
95
|
+
): ReturnType<queries.FindAllByText<T>>
|
|
96
|
+
getByAltText<T extends HTMLElement = HTMLElement>(
|
|
97
|
+
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
|
|
98
|
+
): ReturnType<queries.GetByBoundAttribute<T>>
|
|
99
|
+
getAllByAltText<T extends HTMLElement = HTMLElement>(
|
|
100
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
101
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
102
|
+
queryByAltText<T extends HTMLElement = HTMLElement>(
|
|
103
|
+
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
|
|
104
|
+
): ReturnType<queries.QueryByBoundAttribute<T>>
|
|
105
|
+
queryAllByAltText<T extends HTMLElement = HTMLElement>(
|
|
106
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
107
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
108
|
+
findByAltText<T extends HTMLElement = HTMLElement>(
|
|
109
|
+
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
|
|
110
|
+
): ReturnType<queries.FindByBoundAttribute<T>>
|
|
111
|
+
findAllByAltText<T extends HTMLElement = HTMLElement>(
|
|
112
|
+
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
|
|
113
|
+
): ReturnType<queries.FindAllByBoundAttribute<T>>
|
|
114
|
+
getByTitle<T extends HTMLElement = HTMLElement>(
|
|
115
|
+
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
|
|
116
|
+
): ReturnType<queries.GetByBoundAttribute<T>>
|
|
117
|
+
getAllByTitle<T extends HTMLElement = HTMLElement>(
|
|
118
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
119
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
120
|
+
queryByTitle<T extends HTMLElement = HTMLElement>(
|
|
121
|
+
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
|
|
122
|
+
): ReturnType<queries.QueryByBoundAttribute<T>>
|
|
123
|
+
queryAllByTitle<T extends HTMLElement = HTMLElement>(
|
|
124
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
125
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
126
|
+
findByTitle<T extends HTMLElement = HTMLElement>(
|
|
127
|
+
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
|
|
128
|
+
): ReturnType<queries.FindByBoundAttribute<T>>
|
|
129
|
+
findAllByTitle<T extends HTMLElement = HTMLElement>(
|
|
130
|
+
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
|
|
131
|
+
): ReturnType<queries.FindAllByBoundAttribute<T>>
|
|
132
|
+
getByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
133
|
+
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
|
|
134
|
+
): ReturnType<queries.GetByBoundAttribute<T>>
|
|
135
|
+
getAllByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
136
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
137
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
138
|
+
queryByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
139
|
+
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
|
|
140
|
+
): ReturnType<queries.QueryByBoundAttribute<T>>
|
|
141
|
+
queryAllByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
142
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
143
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
144
|
+
findByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
145
|
+
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
|
|
146
|
+
): ReturnType<queries.FindByBoundAttribute<T>>
|
|
147
|
+
findAllByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
148
|
+
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
|
|
149
|
+
): ReturnType<queries.FindAllByBoundAttribute<T>>
|
|
150
|
+
getByRole<T extends HTMLElement = HTMLElement>(
|
|
151
|
+
...args: Parameters<BoundFunction<queries.GetByRole<T>>>
|
|
152
|
+
): ReturnType<queries.GetByRole<T>>
|
|
153
|
+
getAllByRole<T extends HTMLElement = HTMLElement>(
|
|
154
|
+
...args: Parameters<BoundFunction<queries.AllByRole<T>>>
|
|
155
|
+
): ReturnType<queries.AllByRole<T>>
|
|
156
|
+
queryByRole<T extends HTMLElement = HTMLElement>(
|
|
157
|
+
...args: Parameters<BoundFunction<queries.QueryByRole<T>>>
|
|
158
|
+
): ReturnType<queries.QueryByRole<T>>
|
|
159
|
+
queryAllByRole<T extends HTMLElement = HTMLElement>(
|
|
160
|
+
...args: Parameters<BoundFunction<queries.AllByRole<T>>>
|
|
161
|
+
): ReturnType<queries.AllByRole<T>>
|
|
162
|
+
findByRole<T extends HTMLElement = HTMLElement>(
|
|
163
|
+
...args: Parameters<BoundFunction<queries.FindByRole<T>>>
|
|
164
|
+
): ReturnType<queries.FindByRole<T>>
|
|
165
|
+
findAllByRole<T extends HTMLElement = HTMLElement>(
|
|
166
|
+
...args: Parameters<BoundFunction<queries.FindAllByRole<T>>>
|
|
167
|
+
): ReturnType<queries.FindAllByRole<T>>
|
|
168
|
+
getByTestId<T extends HTMLElement = HTMLElement>(
|
|
169
|
+
...args: Parameters<BoundFunction<queries.GetByBoundAttribute<T>>>
|
|
170
|
+
): ReturnType<queries.GetByBoundAttribute<T>>
|
|
171
|
+
getAllByTestId<T extends HTMLElement = HTMLElement>(
|
|
172
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
173
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
174
|
+
queryByTestId<T extends HTMLElement = HTMLElement>(
|
|
175
|
+
...args: Parameters<BoundFunction<queries.QueryByBoundAttribute<T>>>
|
|
176
|
+
): ReturnType<queries.QueryByBoundAttribute<T>>
|
|
177
|
+
queryAllByTestId<T extends HTMLElement = HTMLElement>(
|
|
178
|
+
...args: Parameters<BoundFunction<queries.AllByBoundAttribute<T>>>
|
|
179
|
+
): ReturnType<queries.AllByBoundAttribute<T>>
|
|
180
|
+
findByTestId<T extends HTMLElement = HTMLElement>(
|
|
181
|
+
...args: Parameters<BoundFunction<queries.FindByBoundAttribute<T>>>
|
|
182
|
+
): ReturnType<queries.FindByBoundAttribute<T>>
|
|
183
|
+
findAllByTestId<T extends HTMLElement = HTMLElement>(
|
|
184
|
+
...args: Parameters<BoundFunction<queries.FindAllByBoundAttribute<T>>>
|
|
185
|
+
): ReturnType<queries.FindAllByBoundAttribute<T>>
|
|
186
|
+
} & {
|
|
187
|
+
[P in keyof Q]: BoundFunction<Q[P]>
|
|
188
|
+
}
|
|
189
|
+
: {
|
|
190
|
+
[P in keyof Q]: BoundFunction<Q[P]>
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export declare function buildQueries<Arguments extends any[]>(
|
|
194
|
+
queryAllBy: GetAllBy<Arguments>,
|
|
195
|
+
getMultipleError: GetErrorFunction<Arguments>,
|
|
196
|
+
getMissingError: GetErrorFunction<Arguments>,
|
|
197
|
+
): BuiltQueryMethods<Arguments>
|
|
198
|
+
|
|
199
|
+
export declare type BuiltQueryMethods<Arguments extends any[]> = [
|
|
200
|
+
QueryBy<Arguments>,
|
|
201
|
+
GetAllBy<Arguments>,
|
|
202
|
+
GetBy<Arguments>,
|
|
203
|
+
FindAllBy<Arguments>,
|
|
204
|
+
FindBy<Arguments>,
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
export declare type ByRoleMatcher = ARIARole | (string & {})
|
|
208
|
+
|
|
209
|
+
export declare interface ByRoleOptions {
|
|
210
|
+
/** suppress suggestions for a specific query */
|
|
211
|
+
suggest?: boolean
|
|
212
|
+
/**
|
|
213
|
+
* If true includes elements in the query set that are usually excluded from
|
|
214
|
+
* the accessibility tree. `role="none"` or `role="presentation"` are included
|
|
215
|
+
* in either case.
|
|
216
|
+
*/
|
|
217
|
+
hidden?: boolean
|
|
218
|
+
/**
|
|
219
|
+
* If true only includes elements in the query set that are marked as
|
|
220
|
+
* selected in the accessibility tree, i.e., `aria-selected="true"`
|
|
221
|
+
*/
|
|
222
|
+
selected?: boolean
|
|
223
|
+
/**
|
|
224
|
+
* If true only includes elements in the query set that are marked as
|
|
225
|
+
* busy in the accessibility tree, i.e., `aria-busy="true"`
|
|
226
|
+
*/
|
|
227
|
+
busy?: boolean
|
|
228
|
+
/**
|
|
229
|
+
* If true only includes elements in the query set that are marked as
|
|
230
|
+
* checked in the accessibility tree, i.e., `aria-checked="true"`
|
|
231
|
+
*/
|
|
232
|
+
checked?: boolean
|
|
233
|
+
/**
|
|
234
|
+
* If true only includes elements in the query set that are marked as
|
|
235
|
+
* pressed in the accessibility tree, i.e., `aria-pressed="true"`
|
|
236
|
+
*/
|
|
237
|
+
pressed?: boolean
|
|
238
|
+
/**
|
|
239
|
+
* Filters elements by their `aria-current` state. `true` and `false` match `aria-current="true"` and `aria-current="false"` (as well as a missing `aria-current` attribute) respectively.
|
|
240
|
+
*/
|
|
241
|
+
current?: boolean | string
|
|
242
|
+
/**
|
|
243
|
+
* If true only includes elements in the query set that are marked as
|
|
244
|
+
* expanded in the accessibility tree, i.e., `aria-expanded="true"`
|
|
245
|
+
*/
|
|
246
|
+
expanded?: boolean
|
|
247
|
+
/**
|
|
248
|
+
* Includes elements with the `"heading"` role matching the indicated level,
|
|
249
|
+
* either by the semantic HTML heading elements `<h1>-<h6>` or matching
|
|
250
|
+
* the `aria-level` attribute.
|
|
251
|
+
*/
|
|
252
|
+
level?: number
|
|
253
|
+
value?: {
|
|
254
|
+
now?: number
|
|
255
|
+
min?: number
|
|
256
|
+
max?: number
|
|
257
|
+
text?: Matcher
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Includes every role used in the `role` attribute
|
|
261
|
+
* For example *ByRole('progressbar', {queryFallbacks: true})` will find <div role="meter progressbar">`.
|
|
262
|
+
*/
|
|
263
|
+
queryFallbacks?: boolean
|
|
264
|
+
/**
|
|
265
|
+
* Only considers elements with the specified accessible name.
|
|
266
|
+
*/
|
|
267
|
+
name?:
|
|
268
|
+
| RegExp
|
|
269
|
+
| string
|
|
270
|
+
| ((accessibleName: string, element: Element) => boolean)
|
|
271
|
+
/**
|
|
272
|
+
* Only considers elements with the specified accessible description.
|
|
273
|
+
*/
|
|
274
|
+
description?:
|
|
275
|
+
| RegExp
|
|
276
|
+
| string
|
|
277
|
+
| ((accessibleDescription: string, element: Element) => boolean)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Cleanup elements rendered to the page and Preact trees that were mounted with render.
|
|
282
|
+
*
|
|
283
|
+
* @public
|
|
284
|
+
*/
|
|
285
|
+
export declare function cleanup(): void;
|
|
286
|
+
|
|
287
|
+
export declare function computeHeadingLevel(element: Element): number | undefined
|
|
288
|
+
|
|
289
|
+
export declare interface Config {
|
|
290
|
+
testIdAttribute: string
|
|
291
|
+
/**
|
|
292
|
+
* WARNING: `unstable` prefix means this API may change in patch and minor releases.
|
|
293
|
+
* @param cb
|
|
294
|
+
*/
|
|
295
|
+
unstable_advanceTimersWrapper(cb: (...args: unknown[]) => unknown): unknown
|
|
296
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
297
|
+
asyncWrapper(cb: (...args: any[]) => any): Promise<any>
|
|
298
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
|
+
eventWrapper(cb: (...args: any[]) => any): void
|
|
300
|
+
asyncUtilTimeout: number
|
|
301
|
+
computedStyleSupportsPseudoElements: boolean
|
|
302
|
+
defaultHidden: boolean
|
|
303
|
+
/** default value for the `ignore` option in `ByText` queries */
|
|
304
|
+
defaultIgnore: string
|
|
305
|
+
showOriginalStackTrace: boolean
|
|
306
|
+
throwSuggestions: boolean
|
|
307
|
+
getElementError: (message: string | null, container: Element) => Error
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export declare interface ConfigFn {
|
|
311
|
+
(existingConfig: Config): Partial<Config>
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export declare function configure(configDelta: ConfigFn | Partial<Config>): void
|
|
315
|
+
|
|
316
|
+
export declare const createEvent: CreateObject & CreateFunction;
|
|
317
|
+
|
|
318
|
+
export declare type CreateFunction = (
|
|
319
|
+
eventName: string,
|
|
320
|
+
node: Document | Element | Window | Node,
|
|
321
|
+
init?: {},
|
|
322
|
+
options?: {EventType?: string; defaultInit?: {}},
|
|
323
|
+
) => Event
|
|
324
|
+
|
|
325
|
+
export declare type CreateObject = {
|
|
326
|
+
[K in EventType]: (
|
|
327
|
+
element: Document | Element | Window | Node,
|
|
328
|
+
options?: {},
|
|
329
|
+
) => Event
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export declare interface DefaultNormalizerOptions {
|
|
333
|
+
trim?: boolean
|
|
334
|
+
collapseWhitespace?: boolean
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* @public
|
|
339
|
+
* The lynx element tree
|
|
340
|
+
*/
|
|
341
|
+
export declare type ElementTree = ReturnType<typeof initElementTree>;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* The Element PAPI Types
|
|
345
|
+
* @public
|
|
346
|
+
*/
|
|
347
|
+
declare type ElementTreeGlobals = PickUnderscoreKeys<ElementTree>;
|
|
348
|
+
|
|
349
|
+
export declare type EventType =
|
|
350
|
+
| 'copy'
|
|
351
|
+
| 'cut'
|
|
352
|
+
| 'paste'
|
|
353
|
+
| 'compositionEnd'
|
|
354
|
+
| 'compositionStart'
|
|
355
|
+
| 'compositionUpdate'
|
|
356
|
+
| 'keyDown'
|
|
357
|
+
| 'keyPress'
|
|
358
|
+
| 'keyUp'
|
|
359
|
+
| 'focus'
|
|
360
|
+
| 'blur'
|
|
361
|
+
| 'focusIn'
|
|
362
|
+
| 'focusOut'
|
|
363
|
+
| 'change'
|
|
364
|
+
| 'input'
|
|
365
|
+
| 'invalid'
|
|
366
|
+
| 'submit'
|
|
367
|
+
| 'reset'
|
|
368
|
+
| 'click'
|
|
369
|
+
| 'contextMenu'
|
|
370
|
+
| 'dblClick'
|
|
371
|
+
| 'drag'
|
|
372
|
+
| 'dragEnd'
|
|
373
|
+
| 'dragEnter'
|
|
374
|
+
| 'dragExit'
|
|
375
|
+
| 'dragLeave'
|
|
376
|
+
| 'dragOver'
|
|
377
|
+
| 'dragStart'
|
|
378
|
+
| 'drop'
|
|
379
|
+
| 'mouseDown'
|
|
380
|
+
| 'mouseEnter'
|
|
381
|
+
| 'mouseLeave'
|
|
382
|
+
| 'mouseMove'
|
|
383
|
+
| 'mouseOut'
|
|
384
|
+
| 'mouseOver'
|
|
385
|
+
| 'mouseUp'
|
|
386
|
+
| 'popState'
|
|
387
|
+
| 'select'
|
|
388
|
+
| 'touchCancel'
|
|
389
|
+
| 'touchEnd'
|
|
390
|
+
| 'touchMove'
|
|
391
|
+
| 'touchStart'
|
|
392
|
+
| 'resize'
|
|
393
|
+
| 'scroll'
|
|
394
|
+
| 'wheel'
|
|
395
|
+
| 'abort'
|
|
396
|
+
| 'canPlay'
|
|
397
|
+
| 'canPlayThrough'
|
|
398
|
+
| 'durationChange'
|
|
399
|
+
| 'emptied'
|
|
400
|
+
| 'encrypted'
|
|
401
|
+
| 'ended'
|
|
402
|
+
| 'loadedData'
|
|
403
|
+
| 'loadedMetadata'
|
|
404
|
+
| 'loadStart'
|
|
405
|
+
| 'pause'
|
|
406
|
+
| 'play'
|
|
407
|
+
| 'playing'
|
|
408
|
+
| 'progress'
|
|
409
|
+
| 'rateChange'
|
|
410
|
+
| 'seeked'
|
|
411
|
+
| 'seeking'
|
|
412
|
+
| 'stalled'
|
|
413
|
+
| 'suspend'
|
|
414
|
+
| 'timeUpdate'
|
|
415
|
+
| 'volumeChange'
|
|
416
|
+
| 'waiting'
|
|
417
|
+
| 'load'
|
|
418
|
+
| 'error'
|
|
419
|
+
| 'animationStart'
|
|
420
|
+
| 'animationEnd'
|
|
421
|
+
| 'animationIteration'
|
|
422
|
+
| 'transitionCancel'
|
|
423
|
+
| 'transitionEnd'
|
|
424
|
+
| 'transitionRun'
|
|
425
|
+
| 'transitionStart'
|
|
426
|
+
| 'doubleClick'
|
|
427
|
+
| 'pointerOver'
|
|
428
|
+
| 'pointerEnter'
|
|
429
|
+
| 'pointerDown'
|
|
430
|
+
| 'pointerMove'
|
|
431
|
+
| 'pointerUp'
|
|
432
|
+
| 'pointerCancel'
|
|
433
|
+
| 'pointerOut'
|
|
434
|
+
| 'pointerLeave'
|
|
435
|
+
| 'gotPointerCapture'
|
|
436
|
+
| 'lostPointerCapture'
|
|
437
|
+
| 'offline'
|
|
438
|
+
| 'online'
|
|
439
|
+
| 'pageHide'
|
|
440
|
+
| 'pageShow'
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* @public
|
|
444
|
+
*/
|
|
445
|
+
declare type FilterUnderscoreKeys<T> = {
|
|
446
|
+
[K in keyof T]: K extends `__${string}` ? K : never;
|
|
447
|
+
}[keyof T];
|
|
448
|
+
|
|
449
|
+
export declare type FindAllBy<Arguments extends any[]> = QueryMethod<
|
|
450
|
+
[Arguments[0], Arguments[1]?, waitForOptions?],
|
|
451
|
+
Promise<HTMLElement[]>
|
|
452
|
+
>
|
|
453
|
+
|
|
454
|
+
export declare function findAllByAltText<T extends HTMLElement = HTMLElement>(
|
|
455
|
+
...args: Parameters<FindAllByBoundAttribute<T>>
|
|
456
|
+
): ReturnType<FindAllByBoundAttribute<T>>
|
|
457
|
+
|
|
458
|
+
export declare type FindAllByBoundAttribute<T extends HTMLElement = HTMLElement> = (
|
|
459
|
+
container: HTMLElement,
|
|
460
|
+
id: Matcher,
|
|
461
|
+
options?: MatcherOptions,
|
|
462
|
+
waitForElementOptions?: waitForOptions,
|
|
463
|
+
) => Promise<T[]>
|
|
464
|
+
|
|
465
|
+
export declare function findAllByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
466
|
+
...args: Parameters<FindAllByBoundAttribute<T>>
|
|
467
|
+
): ReturnType<FindAllByBoundAttribute<T>>
|
|
468
|
+
|
|
469
|
+
export declare function findAllByLabelText<T extends HTMLElement = HTMLElement>(
|
|
470
|
+
...args: Parameters<FindAllByText<T>>
|
|
471
|
+
): ReturnType<FindAllByText<T>>
|
|
472
|
+
|
|
473
|
+
export declare function findAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
474
|
+
...args: Parameters<FindAllByBoundAttribute<T>>
|
|
475
|
+
): ReturnType<FindAllByBoundAttribute<T>>
|
|
476
|
+
|
|
477
|
+
export declare type FindAllByRole<T extends HTMLElement = HTMLElement> = (
|
|
478
|
+
container: HTMLElement,
|
|
479
|
+
role: ByRoleMatcher,
|
|
480
|
+
options?: ByRoleOptions,
|
|
481
|
+
waitForElementOptions?: waitForOptions,
|
|
482
|
+
) => Promise<T[]>
|
|
483
|
+
|
|
484
|
+
export declare function findAllByRole<T extends HTMLElement = HTMLElement>(
|
|
485
|
+
...args: Parameters<FindAllByRole<T>>
|
|
486
|
+
): ReturnType<FindAllByRole<T>>
|
|
487
|
+
|
|
488
|
+
export declare function findAllByTestId<T extends HTMLElement = HTMLElement>(
|
|
489
|
+
...args: Parameters<FindAllByBoundAttribute<T>>
|
|
490
|
+
): ReturnType<FindAllByBoundAttribute<T>>
|
|
491
|
+
|
|
492
|
+
export declare type FindAllByText<T extends HTMLElement = HTMLElement> = (
|
|
493
|
+
container: HTMLElement,
|
|
494
|
+
id: Matcher,
|
|
495
|
+
options?: SelectorMatcherOptions,
|
|
496
|
+
waitForElementOptions?: waitForOptions,
|
|
497
|
+
) => Promise<T[]>
|
|
498
|
+
|
|
499
|
+
export declare function findAllByText<T extends HTMLElement = HTMLElement>(
|
|
500
|
+
...args: Parameters<FindAllByText<T>>
|
|
501
|
+
): ReturnType<FindAllByText<T>>
|
|
502
|
+
|
|
503
|
+
export declare function findAllByTitle<T extends HTMLElement = HTMLElement>(
|
|
504
|
+
...args: Parameters<FindAllByBoundAttribute<T>>
|
|
505
|
+
): ReturnType<FindAllByBoundAttribute<T>>
|
|
506
|
+
|
|
507
|
+
export declare type FindBy<Arguments extends any[]> = QueryMethod<
|
|
508
|
+
[Arguments[0], Arguments[1]?, waitForOptions?],
|
|
509
|
+
Promise<HTMLElement>
|
|
510
|
+
>
|
|
511
|
+
|
|
512
|
+
export declare function findByAltText<T extends HTMLElement = HTMLElement>(
|
|
513
|
+
...args: Parameters<FindByBoundAttribute<T>>
|
|
514
|
+
): ReturnType<FindByBoundAttribute<T>>
|
|
515
|
+
|
|
516
|
+
export declare type FindByBoundAttribute<T extends HTMLElement = HTMLElement> = (
|
|
517
|
+
container: HTMLElement,
|
|
518
|
+
id: Matcher,
|
|
519
|
+
options?: MatcherOptions,
|
|
520
|
+
waitForElementOptions?: waitForOptions,
|
|
521
|
+
) => Promise<T>
|
|
522
|
+
|
|
523
|
+
export declare function findByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
524
|
+
...args: Parameters<FindByBoundAttribute<T>>
|
|
525
|
+
): ReturnType<FindByBoundAttribute<T>>
|
|
526
|
+
|
|
527
|
+
export declare function findByLabelText<T extends HTMLElement = HTMLElement>(
|
|
528
|
+
...args: Parameters<FindByText<T>>
|
|
529
|
+
): ReturnType<FindByText<T>>
|
|
530
|
+
|
|
531
|
+
export declare function findByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
532
|
+
...args: Parameters<FindByBoundAttribute<T>>
|
|
533
|
+
): ReturnType<FindByBoundAttribute<T>>
|
|
534
|
+
|
|
535
|
+
export declare type FindByRole<T extends HTMLElement = HTMLElement> = (
|
|
536
|
+
container: HTMLElement,
|
|
537
|
+
role: ByRoleMatcher,
|
|
538
|
+
options?: ByRoleOptions,
|
|
539
|
+
waitForElementOptions?: waitForOptions,
|
|
540
|
+
) => Promise<T>
|
|
541
|
+
|
|
542
|
+
export declare function findByRole<T extends HTMLElement = HTMLElement>(
|
|
543
|
+
...args: Parameters<FindByRole<T>>
|
|
544
|
+
): ReturnType<FindByRole<T>>
|
|
545
|
+
|
|
546
|
+
export declare function findByTestId<T extends HTMLElement = HTMLElement>(
|
|
547
|
+
...args: Parameters<FindByBoundAttribute<T>>
|
|
548
|
+
): ReturnType<FindByBoundAttribute<T>>
|
|
549
|
+
|
|
550
|
+
export declare type FindByText<T extends HTMLElement = HTMLElement> = (
|
|
551
|
+
container: HTMLElement,
|
|
552
|
+
id: Matcher,
|
|
553
|
+
options?: SelectorMatcherOptions,
|
|
554
|
+
waitForElementOptions?: waitForOptions,
|
|
555
|
+
) => Promise<T>
|
|
556
|
+
|
|
557
|
+
export declare function findByText<T extends HTMLElement = HTMLElement>(
|
|
558
|
+
...args: Parameters<FindByText<T>>
|
|
559
|
+
): ReturnType<FindByText<T>>
|
|
560
|
+
|
|
561
|
+
export declare function findByTitle<T extends HTMLElement = HTMLElement>(
|
|
562
|
+
...args: Parameters<FindByBoundAttribute<T>>
|
|
563
|
+
): ReturnType<FindByBoundAttribute<T>>
|
|
564
|
+
|
|
565
|
+
export declare const fireEvent: FireFunction & FireObject;
|
|
566
|
+
|
|
567
|
+
export declare type FireFunction = (
|
|
568
|
+
element: Document | Element | Window | Node,
|
|
569
|
+
event: Event,
|
|
570
|
+
) => boolean
|
|
571
|
+
|
|
572
|
+
export declare type FireObject = {
|
|
573
|
+
[K in EventType]: (
|
|
574
|
+
element: Document | Element | Window | Node,
|
|
575
|
+
options?: {},
|
|
576
|
+
) => boolean
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export declare type GetAllBy<Arguments extends any[]> = QueryMethod<
|
|
580
|
+
Arguments,
|
|
581
|
+
HTMLElement[]
|
|
582
|
+
>
|
|
583
|
+
|
|
584
|
+
export declare function getAllByAltText<T extends HTMLElement = HTMLElement>(
|
|
585
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
586
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
587
|
+
|
|
588
|
+
export declare function getAllByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
589
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
590
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
591
|
+
|
|
592
|
+
export declare function getAllByLabelText<T extends HTMLElement = HTMLElement>(
|
|
593
|
+
...args: Parameters<AllByText<T>>
|
|
594
|
+
): ReturnType<AllByText<T>>
|
|
595
|
+
|
|
596
|
+
export declare function getAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
597
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
598
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
599
|
+
|
|
600
|
+
export declare function getAllByRole<T extends HTMLElement = HTMLElement>(
|
|
601
|
+
...args: Parameters<AllByRole<T>>
|
|
602
|
+
): ReturnType<AllByRole<T>>
|
|
603
|
+
|
|
604
|
+
export declare function getAllByTestId<T extends HTMLElement = HTMLElement>(
|
|
605
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
606
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
607
|
+
|
|
608
|
+
export declare function getAllByText<T extends HTMLElement = HTMLElement>(
|
|
609
|
+
...args: Parameters<AllByText<T>>
|
|
610
|
+
): ReturnType<AllByText<T>>
|
|
611
|
+
|
|
612
|
+
export declare function getAllByTitle<T extends HTMLElement = HTMLElement>(
|
|
613
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
614
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
615
|
+
|
|
616
|
+
export declare type GetBy<Arguments extends any[]> = QueryMethod<Arguments, HTMLElement>
|
|
617
|
+
|
|
618
|
+
export declare function getByAltText<T extends HTMLElement = HTMLElement>(
|
|
619
|
+
...args: Parameters<GetByBoundAttribute<T>>
|
|
620
|
+
): ReturnType<GetByBoundAttribute<T>>
|
|
621
|
+
|
|
622
|
+
export declare type GetByBoundAttribute<T extends HTMLElement = HTMLElement> = (
|
|
623
|
+
container: HTMLElement,
|
|
624
|
+
id: Matcher,
|
|
625
|
+
options?: MatcherOptions,
|
|
626
|
+
) => T
|
|
627
|
+
|
|
628
|
+
export declare function getByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
629
|
+
...args: Parameters<GetByBoundAttribute<T>>
|
|
630
|
+
): ReturnType<GetByBoundAttribute<T>>
|
|
631
|
+
|
|
632
|
+
export declare function getByLabelText<T extends HTMLElement = HTMLElement>(
|
|
633
|
+
...args: Parameters<GetByText<T>>
|
|
634
|
+
): ReturnType<GetByText<T>>
|
|
635
|
+
|
|
636
|
+
export declare function getByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
637
|
+
...args: Parameters<GetByBoundAttribute<T>>
|
|
638
|
+
): ReturnType<GetByBoundAttribute<T>>
|
|
639
|
+
|
|
640
|
+
export declare type GetByRole<T extends HTMLElement = HTMLElement> = (
|
|
641
|
+
container: HTMLElement,
|
|
642
|
+
role: ByRoleMatcher,
|
|
643
|
+
options?: ByRoleOptions,
|
|
644
|
+
) => T
|
|
645
|
+
|
|
646
|
+
export declare function getByRole<T extends HTMLElement = HTMLElement>(
|
|
647
|
+
...args: Parameters<GetByRole<T>>
|
|
648
|
+
): ReturnType<GetByRole<T>>
|
|
649
|
+
|
|
650
|
+
export declare function getByTestId<T extends HTMLElement = HTMLElement>(
|
|
651
|
+
...args: Parameters<GetByBoundAttribute<T>>
|
|
652
|
+
): ReturnType<GetByBoundAttribute<T>>
|
|
653
|
+
|
|
654
|
+
export declare type GetByText<T extends HTMLElement = HTMLElement> = (
|
|
655
|
+
container: HTMLElement,
|
|
656
|
+
id: Matcher,
|
|
657
|
+
options?: SelectorMatcherOptions,
|
|
658
|
+
) => T
|
|
659
|
+
|
|
660
|
+
export declare function getByText<T extends HTMLElement = HTMLElement>(
|
|
661
|
+
...args: Parameters<GetByText<T>>
|
|
662
|
+
): ReturnType<GetByText<T>>
|
|
663
|
+
|
|
664
|
+
export declare function getByTitle<T extends HTMLElement = HTMLElement>(
|
|
665
|
+
...args: Parameters<GetByBoundAttribute<T>>
|
|
666
|
+
): ReturnType<GetByBoundAttribute<T>>
|
|
667
|
+
|
|
668
|
+
export declare function getConfig(): Config
|
|
669
|
+
|
|
670
|
+
export declare function getDefaultNormalizer(
|
|
671
|
+
options?: DefaultNormalizerOptions,
|
|
672
|
+
): NormalizerFn
|
|
673
|
+
|
|
674
|
+
export declare function getElementError(
|
|
675
|
+
message: string | null,
|
|
676
|
+
container: HTMLElement,
|
|
677
|
+
): Error
|
|
678
|
+
|
|
679
|
+
export declare type GetErrorFunction<Arguments extends any[] = [string]> = (
|
|
680
|
+
c: Element | null,
|
|
681
|
+
...args: Arguments
|
|
682
|
+
) => string
|
|
683
|
+
|
|
684
|
+
export declare function getNodeText(node: HTMLElement): string
|
|
685
|
+
|
|
686
|
+
export declare function getQueriesForElement<
|
|
687
|
+
QueriesToBind extends Queries = typeof queries,
|
|
688
|
+
// Extra type parameter required for reassignment.
|
|
689
|
+
T extends QueriesToBind = QueriesToBind,
|
|
690
|
+
>(element: HTMLElement, queriesToBind?: T): BoundFunctions<T>
|
|
691
|
+
|
|
692
|
+
export declare function getRoles(container: HTMLElement): {
|
|
693
|
+
[index: string]: HTMLElement[]
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export declare function getSuggestedQuery(
|
|
697
|
+
element: HTMLElement,
|
|
698
|
+
variant?: Variant,
|
|
699
|
+
method?: Method,
|
|
700
|
+
): Suggestion | undefined
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* @public
|
|
704
|
+
*/
|
|
705
|
+
declare const initElementTree: () => {
|
|
706
|
+
root: LynxElement | undefined;
|
|
707
|
+
countElement(element: LynxElement, parentComponentUniqueId: number): void;
|
|
708
|
+
__CreatePage(_tag: string, parentComponentUniqueId: number): LynxElement;
|
|
709
|
+
__CreateRawText(text: string): LynxElement;
|
|
710
|
+
__GetElementUniqueID(e: LynxElement): number;
|
|
711
|
+
__SetClasses(e: LynxElement, cls: string): void;
|
|
712
|
+
__CreateElement(tag: string, parentComponentUniqueId: number): LynxElement;
|
|
713
|
+
__CreateView(parentComponentUniqueId: number): LynxElement;
|
|
714
|
+
__CreateScrollView(parentComponentUniqueId: number): LynxElement;
|
|
715
|
+
__FirstElement(e: LynxElement): LynxElement;
|
|
716
|
+
__CreateText(parentComponentUniqueId: number): LynxElement;
|
|
717
|
+
__CreateImage(parentComponentUniqueId: number): LynxElement;
|
|
718
|
+
__CreateWrapperElement(parentComponentUniqueId: number): LynxElement;
|
|
719
|
+
__AddInlineStyle(e: HTMLElement, key: number, value: string): void;
|
|
720
|
+
__AppendElement(parent: LynxElement, child: LynxElement): void;
|
|
721
|
+
__SetCSSId(e: LynxElement | LynxElement[], id: string, entryName?: string): void;
|
|
722
|
+
__SetAttribute(e: LynxElement, key: string, value: any): void;
|
|
723
|
+
__AddEvent(e: LynxElement, eventType: string, eventName: string, eventHandler: string | Record<string, any>): void;
|
|
724
|
+
__GetEvent(e: LynxElement, eventType: string, eventName: string): {
|
|
725
|
+
type: string;
|
|
726
|
+
name: string;
|
|
727
|
+
jsFunction: any;
|
|
728
|
+
} | undefined;
|
|
729
|
+
__SetID(e: LynxElement, id: string): void;
|
|
730
|
+
__SetInlineStyles(e: LynxElement, styles: string | Record<string, string>): void;
|
|
731
|
+
__AddDataset(e: LynxElement, key: string, value: string): void;
|
|
732
|
+
__SetDataset(e: LynxElement, dataset: any): void;
|
|
733
|
+
__SetGestureDetector(e: LynxElement, id: number, type: number, config: any, relationMap: Record<string, number[]>): void;
|
|
734
|
+
__GetDataset(e: LynxElement): DOMStringMap;
|
|
735
|
+
__RemoveElement(parent: LynxElement, child: LynxElement): void;
|
|
736
|
+
__InsertElementBefore(parent: LynxElement, child: LynxElement, ref?: LynxElement): void;
|
|
737
|
+
__ReplaceElement(newElement: LynxElement, oldElement: LynxElement): void;
|
|
738
|
+
__FlushElementTree(): void;
|
|
739
|
+
__UpdateListComponents(_list: LynxElement, _components: string[]): void;
|
|
740
|
+
__UpdateListCallbacks(list: LynxElement, componentAtIndex: (list: LynxElement, listID: number, cellIndex: number, operationID: number, enable_reuse_notification: boolean) => void, enqueueComponent: (list: LynxElement, listID: number, sign: number) => void): void;
|
|
741
|
+
__CreateList(parentComponentUniqueId: number, componentAtIndex: any, enqueueComponent: any): LynxElement;
|
|
742
|
+
__GetTag(ele: LynxElement): string;
|
|
743
|
+
__GetAttributeByName(ele: LynxElement, name: string): string | null;
|
|
744
|
+
clear(): void;
|
|
745
|
+
toTree(): LynxElement | undefined;
|
|
746
|
+
/**
|
|
747
|
+
* Enter a list-item element at the given index.
|
|
748
|
+
* It will load the list-item element using the `componentAtIndex` callback.
|
|
749
|
+
*
|
|
750
|
+
* @param e - The list element
|
|
751
|
+
* @param index - The index of the list-item element
|
|
752
|
+
* @param args - The arguments used to create the list-item element
|
|
753
|
+
* @returns The unique id of the list-item element
|
|
754
|
+
*/
|
|
755
|
+
enterListItemAtIndex(e: LynxElement, index: number, ...args: any[]): number;
|
|
756
|
+
/**
|
|
757
|
+
* Leave a list-item element.
|
|
758
|
+
* It will mark the list-item element as unused using
|
|
759
|
+
* the `enqueueComponent` callback, and the list-item element
|
|
760
|
+
* will be reused in the future by other list-item elements.
|
|
761
|
+
*
|
|
762
|
+
* @param e - The list element
|
|
763
|
+
* @param uiSign - The unique id of the list-item element
|
|
764
|
+
*/
|
|
765
|
+
leaveListItem(e: LynxElement, uiSign: number): void;
|
|
766
|
+
toJSON(): LynxElement | undefined;
|
|
767
|
+
__GetElementByUniqueId(uniqueId: number): LynxElement | undefined;
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* https://testing-library.com/docs/dom-testing-library/api-helpers#isinaccessible
|
|
772
|
+
*/
|
|
773
|
+
export declare function isInaccessible(element: Element): boolean
|
|
774
|
+
|
|
775
|
+
export declare function logDOM(
|
|
776
|
+
dom?: Element | HTMLDocument,
|
|
777
|
+
maxLength?: number,
|
|
778
|
+
options?: PrettyDOMOptions,
|
|
779
|
+
): void
|
|
780
|
+
|
|
781
|
+
export declare function logRoles(
|
|
782
|
+
container: HTMLElement,
|
|
783
|
+
options?: LogRolesOptions,
|
|
784
|
+
): string
|
|
785
|
+
|
|
786
|
+
export declare interface LogRolesOptions {
|
|
787
|
+
hidden?: boolean
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Any Lynx Element, such as `view`, `text`, `image`, etc.
|
|
792
|
+
*
|
|
793
|
+
* {@link https://lynxjs.org/living-spec/index.html?ts=1743416098203#element%E2%91%A0 | Lynx Spec Reference}
|
|
794
|
+
*
|
|
795
|
+
* @public
|
|
796
|
+
*/
|
|
797
|
+
declare interface LynxElement extends HTMLElement {
|
|
798
|
+
/**
|
|
799
|
+
* The map of events bound to the element.
|
|
800
|
+
*/
|
|
801
|
+
eventMap?: {
|
|
802
|
+
[key: string]: any;
|
|
803
|
+
};
|
|
804
|
+
/**
|
|
805
|
+
* The gestures bound to the element.
|
|
806
|
+
*/
|
|
807
|
+
gesture?: {
|
|
808
|
+
[key: string]: any;
|
|
809
|
+
};
|
|
810
|
+
/**
|
|
811
|
+
* The cssId of the element
|
|
812
|
+
*/
|
|
813
|
+
cssId?: string;
|
|
814
|
+
/**
|
|
815
|
+
* Returns the first child.
|
|
816
|
+
*
|
|
817
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Node/firstChild | MDN Reference}
|
|
818
|
+
*/
|
|
819
|
+
firstChild: LynxElement;
|
|
820
|
+
/**
|
|
821
|
+
* Returns the next sibling.
|
|
822
|
+
*
|
|
823
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Node/nextSibling | MDN Reference}
|
|
824
|
+
*/
|
|
825
|
+
nextSibling: LynxElement;
|
|
826
|
+
/**
|
|
827
|
+
* Returns the parent.
|
|
828
|
+
*
|
|
829
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Node/parentNode | MDN Reference}
|
|
830
|
+
*/
|
|
831
|
+
parentNode: LynxElement;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* A pure-JavaScript implementation of the {@link https://lynxjs.org/guide/spec.html | Lynx Spec},
|
|
836
|
+
* notably the {@link https://lynxjs.org/api/engine/element-api | Element PAPI} and {@link https://lynxjs.org/guide/spec#dual-threaded-model | Dual-threaded Model} for use with Node.js.
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
*
|
|
840
|
+
* ```ts
|
|
841
|
+
* import { LynxEnv } from '@lynx-js/test-environment';
|
|
842
|
+
*
|
|
843
|
+
* const lynxEnv = new LynxEnv();
|
|
844
|
+
*
|
|
845
|
+
* lynxEnv.switchToMainThread();
|
|
846
|
+
* // use the main thread Element PAPI
|
|
847
|
+
* const page = __CreatePage('0', 0);
|
|
848
|
+
* const view = __CreateView(0);
|
|
849
|
+
* __AppendElement(page, view);
|
|
850
|
+
*
|
|
851
|
+
* ```
|
|
852
|
+
*
|
|
853
|
+
* @public
|
|
854
|
+
*/
|
|
855
|
+
export declare class LynxEnv {
|
|
856
|
+
private originals;
|
|
857
|
+
/**
|
|
858
|
+
* The global object for the background thread.
|
|
859
|
+
*
|
|
860
|
+
* @example
|
|
861
|
+
*
|
|
862
|
+
* ```ts
|
|
863
|
+
* import { LynxEnv } from '@lynx-js/test-environment';
|
|
864
|
+
*
|
|
865
|
+
* const lynxEnv = new LynxEnv();
|
|
866
|
+
*
|
|
867
|
+
* lynxEnv.switchToBackgroundThread();
|
|
868
|
+
* // use the background thread global object
|
|
869
|
+
* globalThis.lynxCoreInject.tt.OnLifecycleEvent(...args);
|
|
870
|
+
* ```
|
|
871
|
+
*/
|
|
872
|
+
backgroundThread: LynxGlobalThis;
|
|
873
|
+
/**
|
|
874
|
+
* The global object for the main thread.
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
*
|
|
878
|
+
* ```ts
|
|
879
|
+
* import { LynxEnv } from '@lynx-js/test-environment';
|
|
880
|
+
*
|
|
881
|
+
* const lynxEnv = new LynxEnv();
|
|
882
|
+
*
|
|
883
|
+
* lynxEnv.switchToMainThread();
|
|
884
|
+
* // use the main thread global object
|
|
885
|
+
* const page = globalThis.__CreatePage('0', 0);
|
|
886
|
+
* const view = globalThis.__CreateView(0);
|
|
887
|
+
* globalThis.__AppendElement(page, view);
|
|
888
|
+
* ```
|
|
889
|
+
*/
|
|
890
|
+
mainThread: LynxGlobalThis & ElementTreeGlobals;
|
|
891
|
+
jsdom: JSDOM;
|
|
892
|
+
constructor();
|
|
893
|
+
injectGlobals(): void;
|
|
894
|
+
switchToBackgroundThread(): void;
|
|
895
|
+
switchToMainThread(): void;
|
|
896
|
+
clearGlobal(): void;
|
|
897
|
+
resetLynxEnv(): void;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* The `globalThis` object of Lynx dual thread environment.
|
|
902
|
+
*
|
|
903
|
+
* @public
|
|
904
|
+
*/
|
|
905
|
+
declare interface LynxGlobalThis {
|
|
906
|
+
/**
|
|
907
|
+
* The globalThis object.
|
|
908
|
+
*/
|
|
909
|
+
globalThis: LynxGlobalThis;
|
|
910
|
+
[key: string]: any;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
export declare type Match = (
|
|
914
|
+
textToMatch: string,
|
|
915
|
+
node: HTMLElement | null,
|
|
916
|
+
matcher: Matcher,
|
|
917
|
+
options?: MatcherOptions,
|
|
918
|
+
) => boolean
|
|
919
|
+
|
|
920
|
+
export declare type Matcher = MatcherFunction | RegExp | number | string
|
|
921
|
+
|
|
922
|
+
export declare type MatcherFunction = (
|
|
923
|
+
content: string,
|
|
924
|
+
element: Element | null,
|
|
925
|
+
) => boolean
|
|
926
|
+
|
|
927
|
+
export declare interface MatcherOptions {
|
|
928
|
+
exact?: boolean
|
|
929
|
+
/** Use normalizer with getDefaultNormalizer instead */
|
|
930
|
+
trim?: boolean
|
|
931
|
+
/** Use normalizer with getDefaultNormalizer instead */
|
|
932
|
+
collapseWhitespace?: boolean
|
|
933
|
+
normalizer?: NormalizerFn
|
|
934
|
+
/** suppress suggestions for a specific query */
|
|
935
|
+
suggest?: boolean
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
export declare type Method =
|
|
939
|
+
| 'AltText'
|
|
940
|
+
| 'alttext'
|
|
941
|
+
| 'DisplayValue'
|
|
942
|
+
| 'displayvalue'
|
|
943
|
+
| 'LabelText'
|
|
944
|
+
| 'labeltext'
|
|
945
|
+
| 'PlaceholderText'
|
|
946
|
+
| 'placeholdertext'
|
|
947
|
+
| 'Role'
|
|
948
|
+
| 'role'
|
|
949
|
+
| 'TestId'
|
|
950
|
+
| 'testid'
|
|
951
|
+
| 'Text'
|
|
952
|
+
| 'text'
|
|
953
|
+
| 'Title'
|
|
954
|
+
| 'title'
|
|
955
|
+
|
|
956
|
+
export declare type NormalizerFn = (text: string) => string
|
|
957
|
+
|
|
958
|
+
export declare interface NormalizerOptions extends DefaultNormalizerOptions {
|
|
959
|
+
normalizer?: NormalizerFn
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* @public
|
|
964
|
+
*/
|
|
965
|
+
declare type PickUnderscoreKeys<T> = Pick<T, FilterUnderscoreKeys<T>>;
|
|
966
|
+
|
|
967
|
+
export declare function prettyDOM(
|
|
968
|
+
dom?: Element | HTMLDocument,
|
|
969
|
+
maxLength?: number,
|
|
970
|
+
options?: PrettyDOMOptions,
|
|
971
|
+
): string | false
|
|
972
|
+
|
|
973
|
+
export declare interface PrettyDOMOptions extends prettyFormat.OptionsReceived {
|
|
974
|
+
/**
|
|
975
|
+
* Given a `Node` return `false` if you wish to ignore that node in the output.
|
|
976
|
+
* By default, ignores `<style />`, `<script />` and comment nodes.
|
|
977
|
+
*/
|
|
978
|
+
filterNode?: (node: Node) => boolean
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
export { prettyFormat }
|
|
982
|
+
|
|
983
|
+
export declare interface Queries {
|
|
984
|
+
[T: string]: Query
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
declare namespace queries {
|
|
988
|
+
export {
|
|
989
|
+
getByLabelText,
|
|
990
|
+
getAllByLabelText,
|
|
991
|
+
queryByLabelText,
|
|
992
|
+
queryAllByLabelText,
|
|
993
|
+
findByLabelText,
|
|
994
|
+
findAllByLabelText,
|
|
995
|
+
getByPlaceholderText,
|
|
996
|
+
getAllByPlaceholderText,
|
|
997
|
+
queryByPlaceholderText,
|
|
998
|
+
queryAllByPlaceholderText,
|
|
999
|
+
findByPlaceholderText,
|
|
1000
|
+
findAllByPlaceholderText,
|
|
1001
|
+
getByText,
|
|
1002
|
+
getAllByText,
|
|
1003
|
+
queryByText,
|
|
1004
|
+
queryAllByText,
|
|
1005
|
+
findByText,
|
|
1006
|
+
findAllByText,
|
|
1007
|
+
getByAltText,
|
|
1008
|
+
getAllByAltText,
|
|
1009
|
+
queryByAltText,
|
|
1010
|
+
queryAllByAltText,
|
|
1011
|
+
findByAltText,
|
|
1012
|
+
findAllByAltText,
|
|
1013
|
+
getByTitle,
|
|
1014
|
+
getAllByTitle,
|
|
1015
|
+
queryByTitle,
|
|
1016
|
+
queryAllByTitle,
|
|
1017
|
+
findByTitle,
|
|
1018
|
+
findAllByTitle,
|
|
1019
|
+
getByDisplayValue,
|
|
1020
|
+
getAllByDisplayValue,
|
|
1021
|
+
queryByDisplayValue,
|
|
1022
|
+
queryAllByDisplayValue,
|
|
1023
|
+
findByDisplayValue,
|
|
1024
|
+
findAllByDisplayValue,
|
|
1025
|
+
getByRole,
|
|
1026
|
+
getAllByRole,
|
|
1027
|
+
queryByRole,
|
|
1028
|
+
queryAllByRole,
|
|
1029
|
+
findByRole,
|
|
1030
|
+
findAllByRole,
|
|
1031
|
+
getByTestId,
|
|
1032
|
+
getAllByTestId,
|
|
1033
|
+
queryByTestId,
|
|
1034
|
+
queryAllByTestId,
|
|
1035
|
+
findByTestId,
|
|
1036
|
+
findAllByTestId,
|
|
1037
|
+
QueryByBoundAttribute,
|
|
1038
|
+
AllByBoundAttribute,
|
|
1039
|
+
FindAllByBoundAttribute,
|
|
1040
|
+
GetByBoundAttribute,
|
|
1041
|
+
FindByBoundAttribute,
|
|
1042
|
+
QueryByText,
|
|
1043
|
+
AllByText,
|
|
1044
|
+
FindAllByText,
|
|
1045
|
+
GetByText,
|
|
1046
|
+
FindByText,
|
|
1047
|
+
ByRoleOptions,
|
|
1048
|
+
AllByRole,
|
|
1049
|
+
GetByRole,
|
|
1050
|
+
QueryByRole,
|
|
1051
|
+
FindByRole,
|
|
1052
|
+
FindAllByRole
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
export { queries }
|
|
1056
|
+
|
|
1057
|
+
export declare type Query = (
|
|
1058
|
+
container: HTMLElement,
|
|
1059
|
+
...args: any[]
|
|
1060
|
+
) =>
|
|
1061
|
+
| Error
|
|
1062
|
+
| HTMLElement
|
|
1063
|
+
| HTMLElement[]
|
|
1064
|
+
| Promise<HTMLElement[]>
|
|
1065
|
+
| Promise<HTMLElement>
|
|
1066
|
+
| null
|
|
1067
|
+
|
|
1068
|
+
export declare function queryAllByAltText<T extends HTMLElement = HTMLElement>(
|
|
1069
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
1070
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
1071
|
+
|
|
1072
|
+
export declare const queryAllByAttribute: AllByAttribute;
|
|
1073
|
+
|
|
1074
|
+
export declare function queryAllByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
1075
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
1076
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
1077
|
+
|
|
1078
|
+
export declare function queryAllByLabelText<T extends HTMLElement = HTMLElement>(
|
|
1079
|
+
...args: Parameters<AllByText<T>>
|
|
1080
|
+
): ReturnType<AllByText<T>>
|
|
1081
|
+
|
|
1082
|
+
export declare function queryAllByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
1083
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
1084
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
1085
|
+
|
|
1086
|
+
export declare function queryAllByRole<T extends HTMLElement = HTMLElement>(
|
|
1087
|
+
...args: Parameters<AllByRole<T>>
|
|
1088
|
+
): ReturnType<AllByRole<T>>
|
|
1089
|
+
|
|
1090
|
+
export declare function queryAllByTestId<T extends HTMLElement = HTMLElement>(
|
|
1091
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
1092
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
1093
|
+
|
|
1094
|
+
export declare function queryAllByText<T extends HTMLElement = HTMLElement>(
|
|
1095
|
+
...args: Parameters<AllByText<T>>
|
|
1096
|
+
): ReturnType<AllByText<T>>
|
|
1097
|
+
|
|
1098
|
+
export declare function queryAllByTitle<T extends HTMLElement = HTMLElement>(
|
|
1099
|
+
...args: Parameters<AllByBoundAttribute<T>>
|
|
1100
|
+
): ReturnType<AllByBoundAttribute<T>>
|
|
1101
|
+
|
|
1102
|
+
export declare type QueryArgs = [string, QueryOptions?]
|
|
1103
|
+
|
|
1104
|
+
export declare type QueryBy<Arguments extends any[]> = QueryMethod<
|
|
1105
|
+
Arguments,
|
|
1106
|
+
HTMLElement | null
|
|
1107
|
+
>
|
|
1108
|
+
|
|
1109
|
+
export declare function queryByAltText<T extends HTMLElement = HTMLElement>(
|
|
1110
|
+
...args: Parameters<QueryByBoundAttribute<T>>
|
|
1111
|
+
): ReturnType<QueryByBoundAttribute<T>>
|
|
1112
|
+
|
|
1113
|
+
export declare type QueryByAttribute = (
|
|
1114
|
+
attribute: string,
|
|
1115
|
+
container: HTMLElement,
|
|
1116
|
+
id: Matcher,
|
|
1117
|
+
options?: MatcherOptions,
|
|
1118
|
+
) => HTMLElement | null
|
|
1119
|
+
|
|
1120
|
+
export declare const queryByAttribute: QueryByAttribute;
|
|
1121
|
+
|
|
1122
|
+
export declare type QueryByBoundAttribute<T extends HTMLElement = HTMLElement> = (
|
|
1123
|
+
container: HTMLElement,
|
|
1124
|
+
id: Matcher,
|
|
1125
|
+
options?: MatcherOptions,
|
|
1126
|
+
) => T | null
|
|
1127
|
+
|
|
1128
|
+
export declare function queryByDisplayValue<T extends HTMLElement = HTMLElement>(
|
|
1129
|
+
...args: Parameters<QueryByBoundAttribute<T>>
|
|
1130
|
+
): ReturnType<QueryByBoundAttribute<T>>
|
|
1131
|
+
|
|
1132
|
+
export declare function queryByLabelText<T extends HTMLElement = HTMLElement>(
|
|
1133
|
+
...args: Parameters<QueryByText<T>>
|
|
1134
|
+
): ReturnType<QueryByText<T>>
|
|
1135
|
+
|
|
1136
|
+
export declare function queryByPlaceholderText<T extends HTMLElement = HTMLElement>(
|
|
1137
|
+
...args: Parameters<QueryByBoundAttribute<T>>
|
|
1138
|
+
): ReturnType<QueryByBoundAttribute<T>>
|
|
1139
|
+
|
|
1140
|
+
export declare type QueryByRole<T extends HTMLElement = HTMLElement> = (
|
|
1141
|
+
container: HTMLElement,
|
|
1142
|
+
role: ByRoleMatcher,
|
|
1143
|
+
options?: ByRoleOptions,
|
|
1144
|
+
) => T | null
|
|
1145
|
+
|
|
1146
|
+
export declare function queryByRole<T extends HTMLElement = HTMLElement>(
|
|
1147
|
+
...args: Parameters<QueryByRole<T>>
|
|
1148
|
+
): ReturnType<QueryByRole<T>>
|
|
1149
|
+
|
|
1150
|
+
export declare function queryByTestId<T extends HTMLElement = HTMLElement>(
|
|
1151
|
+
...args: Parameters<QueryByBoundAttribute<T>>
|
|
1152
|
+
): ReturnType<QueryByBoundAttribute<T>>
|
|
1153
|
+
|
|
1154
|
+
export declare type QueryByText<T extends HTMLElement = HTMLElement> = (
|
|
1155
|
+
container: HTMLElement,
|
|
1156
|
+
id: Matcher,
|
|
1157
|
+
options?: SelectorMatcherOptions,
|
|
1158
|
+
) => T | null
|
|
1159
|
+
|
|
1160
|
+
export declare function queryByText<T extends HTMLElement = HTMLElement>(
|
|
1161
|
+
...args: Parameters<QueryByText<T>>
|
|
1162
|
+
): ReturnType<QueryByText<T>>
|
|
1163
|
+
|
|
1164
|
+
export declare function queryByTitle<T extends HTMLElement = HTMLElement>(
|
|
1165
|
+
...args: Parameters<QueryByBoundAttribute<T>>
|
|
1166
|
+
): ReturnType<QueryByBoundAttribute<T>>
|
|
1167
|
+
|
|
1168
|
+
declare namespace queryHelpers {
|
|
1169
|
+
export {
|
|
1170
|
+
getElementError,
|
|
1171
|
+
buildQueries,
|
|
1172
|
+
WithSuggest,
|
|
1173
|
+
GetErrorFunction,
|
|
1174
|
+
SelectorMatcherOptions,
|
|
1175
|
+
QueryByAttribute,
|
|
1176
|
+
AllByAttribute,
|
|
1177
|
+
queryByAttribute,
|
|
1178
|
+
queryAllByAttribute,
|
|
1179
|
+
QueryMethod,
|
|
1180
|
+
QueryBy,
|
|
1181
|
+
GetAllBy,
|
|
1182
|
+
FindAllBy,
|
|
1183
|
+
GetBy,
|
|
1184
|
+
FindBy,
|
|
1185
|
+
BuiltQueryMethods
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
export { queryHelpers }
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* query methods have a common call signature. Only the return type differs.
|
|
1192
|
+
*/
|
|
1193
|
+
export declare type QueryMethod<Arguments extends any[], Return> = (
|
|
1194
|
+
container: HTMLElement,
|
|
1195
|
+
...args: Arguments
|
|
1196
|
+
) => Return
|
|
1197
|
+
|
|
1198
|
+
export declare interface QueryOptions {
|
|
1199
|
+
[key: string]: RegExp | boolean
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Render into the page. It should be used with cleanup.
|
|
1204
|
+
*
|
|
1205
|
+
* @example
|
|
1206
|
+
*
|
|
1207
|
+
* ```ts
|
|
1208
|
+
* import { render} from '@lynx-js/react/testing-library'
|
|
1209
|
+
*
|
|
1210
|
+
* const WrapperComponent = ({ children }) => (
|
|
1211
|
+
* <view data-testid='wrapper'>{children}</view>
|
|
1212
|
+
* );
|
|
1213
|
+
* const Comp = () => {
|
|
1214
|
+
* return <view data-testid='inner' style="background-color: yellow;" />;
|
|
1215
|
+
* };
|
|
1216
|
+
* const { container, getByTestId } = render(<Comp />, {
|
|
1217
|
+
* wrapper: WrapperComponent,
|
|
1218
|
+
* });
|
|
1219
|
+
* expect(getByTestId('wrapper')).toBeInTheDocument();
|
|
1220
|
+
* expect(container.firstChild).toMatchInlineSnapshot(`
|
|
1221
|
+
* <view
|
|
1222
|
+
* data-testid="wrapper"
|
|
1223
|
+
* >
|
|
1224
|
+
* <view
|
|
1225
|
+
* data-testid="inner"
|
|
1226
|
+
* style="background-color: yellow;"
|
|
1227
|
+
* />
|
|
1228
|
+
* </view>
|
|
1229
|
+
* `);
|
|
1230
|
+
* ```
|
|
1231
|
+
*
|
|
1232
|
+
* @public
|
|
1233
|
+
*/
|
|
1234
|
+
export declare function render<Q extends Queries>(
|
|
1235
|
+
ui: ComponentChild,
|
|
1236
|
+
options?: RenderOptions<Q>,
|
|
1237
|
+
): RenderResult<Q>;
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Allows you to render a hook within a test React component without having to
|
|
1241
|
+
* create that component yourself.
|
|
1242
|
+
*
|
|
1243
|
+
* @example
|
|
1244
|
+
*
|
|
1245
|
+
* ```ts
|
|
1246
|
+
* import { renderHook } from '@lynx-js/react/testing-library'
|
|
1247
|
+
*
|
|
1248
|
+
* const Context = createContext('default');
|
|
1249
|
+
* function Wrapper({ children }) {
|
|
1250
|
+
* return <Context.Provider value='provided'>{children}</Context.Provider>;
|
|
1251
|
+
* }
|
|
1252
|
+
* const { result } = renderHook(
|
|
1253
|
+
* () => {
|
|
1254
|
+
* return useContext(Context);
|
|
1255
|
+
* },
|
|
1256
|
+
* {
|
|
1257
|
+
* wrapper: Wrapper,
|
|
1258
|
+
* },
|
|
1259
|
+
* );
|
|
1260
|
+
*
|
|
1261
|
+
* expect(result.current).toEqual('provided');
|
|
1262
|
+
* ```
|
|
1263
|
+
*
|
|
1264
|
+
* @public
|
|
1265
|
+
*/
|
|
1266
|
+
export declare function renderHook<Result, Props>(
|
|
1267
|
+
render: (initialProps: Props) => Result,
|
|
1268
|
+
options?: RenderHookOptions<Props>,
|
|
1269
|
+
): RenderHookResult<Result, Props>;
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* The options for {@link renderHook}
|
|
1273
|
+
*
|
|
1274
|
+
* @public
|
|
1275
|
+
*/
|
|
1276
|
+
export declare interface RenderHookOptions<Props> {
|
|
1277
|
+
/**
|
|
1278
|
+
* The argument passed to the renderHook callback. Can be useful if you plan
|
|
1279
|
+
* to use the rerender utility to change the values passed to your hook.
|
|
1280
|
+
*/
|
|
1281
|
+
initialProps?: Props;
|
|
1282
|
+
/**
|
|
1283
|
+
* Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
|
|
1284
|
+
* reusable custom render functions for common data providers. See setup for examples.
|
|
1285
|
+
*
|
|
1286
|
+
* @example
|
|
1287
|
+
*
|
|
1288
|
+
* ```ts
|
|
1289
|
+
* import { renderHook } from '@lynx-js/react/testing-library'
|
|
1290
|
+
* import { ThemeProvider } from 'my-ui-lib'
|
|
1291
|
+
* import { TranslationProvider } from 'my-i18n-lib'
|
|
1292
|
+
* import defaultStrings from 'i18n/en-x-default'
|
|
1293
|
+
*
|
|
1294
|
+
* const AllTheProviders = ({children}) => {
|
|
1295
|
+
* return (
|
|
1296
|
+
* <ThemeProvider theme="light">
|
|
1297
|
+
* <TranslationProvider messages={defaultStrings}>
|
|
1298
|
+
* {children}
|
|
1299
|
+
* </TranslationProvider>
|
|
1300
|
+
* </ThemeProvider>
|
|
1301
|
+
* )
|
|
1302
|
+
* }
|
|
1303
|
+
*
|
|
1304
|
+
* const customRenderHook = (ui, options) =>
|
|
1305
|
+
* renderHook(ui, { wrapper: AllTheProviders, ...options })
|
|
1306
|
+
*
|
|
1307
|
+
* // re-export everything
|
|
1308
|
+
* export * from '@lynx-js/react/testing-library'
|
|
1309
|
+
*
|
|
1310
|
+
* // override renderHook method
|
|
1311
|
+
* export { customRender as renderHook }
|
|
1312
|
+
* ```
|
|
1313
|
+
*/
|
|
1314
|
+
wrapper?: ComponentType<{ children: LynxElement }>;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* The result of {@link renderHook}
|
|
1319
|
+
*
|
|
1320
|
+
* @public
|
|
1321
|
+
*/
|
|
1322
|
+
|
|
1323
|
+
export declare interface RenderHookResult<Result, Props> {
|
|
1324
|
+
/**
|
|
1325
|
+
* Triggers a re-render. The props will be passed to your renderHook callback.
|
|
1326
|
+
*/
|
|
1327
|
+
rerender: (props?: Props) => void;
|
|
1328
|
+
/**
|
|
1329
|
+
* This is a stable reference to the latest value returned by your renderHook
|
|
1330
|
+
* callback
|
|
1331
|
+
*/
|
|
1332
|
+
result: {
|
|
1333
|
+
/**
|
|
1334
|
+
* The value returned by your renderHook callback
|
|
1335
|
+
*/
|
|
1336
|
+
current: Result;
|
|
1337
|
+
};
|
|
1338
|
+
/**
|
|
1339
|
+
* Unmounts the test component. This is useful for when you need to test
|
|
1340
|
+
* any cleanup your useEffects have.
|
|
1341
|
+
*/
|
|
1342
|
+
unmount: () => void;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* The options for {@link render}.
|
|
1347
|
+
*
|
|
1348
|
+
* @public
|
|
1349
|
+
*/
|
|
1350
|
+
export declare interface RenderOptions<Q extends Queries = typeof queries> {
|
|
1351
|
+
/**
|
|
1352
|
+
* Queries to bind. Overrides the default set from DOM Testing Library unless merged.
|
|
1353
|
+
*
|
|
1354
|
+
* @example
|
|
1355
|
+
*
|
|
1356
|
+
* ```ts
|
|
1357
|
+
* // Example, a function to traverse table contents
|
|
1358
|
+
* import * as tableQueries from 'my-table-query-library'
|
|
1359
|
+
* import { queries } from '@lynx-js/react/testing-library'
|
|
1360
|
+
*
|
|
1361
|
+
* const { getByRowColumn, getByText } = render(<MyTable />, {
|
|
1362
|
+
* queries: {...queries, ...tableQueries},
|
|
1363
|
+
* })
|
|
1364
|
+
*
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
1367
|
+
queries?: Q;
|
|
1368
|
+
/**
|
|
1369
|
+
* Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
|
|
1370
|
+
* reusable custom render functions for common data providers. See setup for examples.
|
|
1371
|
+
*
|
|
1372
|
+
* @example
|
|
1373
|
+
*
|
|
1374
|
+
* ```ts
|
|
1375
|
+
* import { render } from '@lynx-js/react/testing-library'
|
|
1376
|
+
* import { ThemeProvider } from 'my-ui-lib'
|
|
1377
|
+
* import { TranslationProvider } from 'my-i18n-lib'
|
|
1378
|
+
* import defaultStrings from 'i18n/en-x-default'
|
|
1379
|
+
*
|
|
1380
|
+
* const AllTheProviders = ({children}) => {
|
|
1381
|
+
* return (
|
|
1382
|
+
* <ThemeProvider theme="light">
|
|
1383
|
+
* <TranslationProvider messages={defaultStrings}>
|
|
1384
|
+
* {children}
|
|
1385
|
+
* </TranslationProvider>
|
|
1386
|
+
* </ThemeProvider>
|
|
1387
|
+
* )
|
|
1388
|
+
* }
|
|
1389
|
+
*
|
|
1390
|
+
* const customRender = (ui, options) =>
|
|
1391
|
+
* render(ui, { wrapper: AllTheProviders, ...options })
|
|
1392
|
+
*
|
|
1393
|
+
* // re-export everything
|
|
1394
|
+
* export * from '@lynx-js/react/testing-library'
|
|
1395
|
+
*
|
|
1396
|
+
* // override render method
|
|
1397
|
+
* export { customRender as render }
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
wrapper?: ComponentChild;
|
|
1401
|
+
/**
|
|
1402
|
+
* Render your component in the main thread or not.
|
|
1403
|
+
*
|
|
1404
|
+
* It is recommended to use this option only when you need to test the {@link https://lynxjs.org/zh/guide/interaction/ifr.html | IFR} behavior.
|
|
1405
|
+
*
|
|
1406
|
+
* @defaultValue false
|
|
1407
|
+
*/
|
|
1408
|
+
enableMainThread?: boolean;
|
|
1409
|
+
/**
|
|
1410
|
+
* Render your component in the background thread or not.
|
|
1411
|
+
*
|
|
1412
|
+
* Note that all user code in the top level will be executed in the background thread by default. (eg. `__BACKGROUND__` is `true` in the top level)
|
|
1413
|
+
*
|
|
1414
|
+
* @defaultValue true
|
|
1415
|
+
*/
|
|
1416
|
+
enableBackgroundThread?: boolean;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* The result of {@link render}
|
|
1421
|
+
*
|
|
1422
|
+
* @public
|
|
1423
|
+
*/
|
|
1424
|
+
export declare type RenderResult<Q extends Queries = typeof queries> = {
|
|
1425
|
+
container: LynxElement;
|
|
1426
|
+
rerender: (ui: ComponentChild) => void;
|
|
1427
|
+
unmount: () => boolean;
|
|
1428
|
+
} & { [P in keyof Q]: BoundFunction<Q[P]> };
|
|
1429
|
+
|
|
1430
|
+
declare type Screen_2<Q extends Queries = typeof queries> = BoundFunctions<Q> & {
|
|
1431
|
+
/**
|
|
1432
|
+
* Convenience function for `pretty-dom` which also allows an array
|
|
1433
|
+
* of elements
|
|
1434
|
+
*/
|
|
1435
|
+
debug: (
|
|
1436
|
+
element?: Array<Element | HTMLDocument> | Element | HTMLDocument,
|
|
1437
|
+
maxLength?: number,
|
|
1438
|
+
options?: OptionsReceived,
|
|
1439
|
+
) => void
|
|
1440
|
+
/**
|
|
1441
|
+
* Convenience function for `Testing Playground` which logs and returns the URL that
|
|
1442
|
+
* can be opened in a browser
|
|
1443
|
+
*/
|
|
1444
|
+
logTestingPlaygroundURL: (element?: Element | HTMLDocument) => string
|
|
1445
|
+
}
|
|
1446
|
+
export { Screen_2 as Screen }
|
|
1447
|
+
|
|
1448
|
+
declare const screen_2: Screen_2;
|
|
1449
|
+
export { screen_2 as screen }
|
|
1450
|
+
|
|
1451
|
+
export declare interface SelectorMatcherOptions extends MatcherOptions {
|
|
1452
|
+
selector?: string
|
|
1453
|
+
ignore?: boolean | string
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
export declare interface Suggestion {
|
|
1457
|
+
queryName: string
|
|
1458
|
+
queryMethod: string
|
|
1459
|
+
queryArgs: QueryArgs
|
|
1460
|
+
variant: string
|
|
1461
|
+
warning?: string
|
|
1462
|
+
toString(): string
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
export declare type Variant =
|
|
1466
|
+
| 'find'
|
|
1467
|
+
| 'findAll'
|
|
1468
|
+
| 'get'
|
|
1469
|
+
| 'getAll'
|
|
1470
|
+
| 'query'
|
|
1471
|
+
| 'queryAll'
|
|
1472
|
+
|
|
1473
|
+
export declare function waitFor<T>(
|
|
1474
|
+
callback: () => Promise<T> | T,
|
|
1475
|
+
options?: waitForOptions,
|
|
1476
|
+
): Promise<T>
|
|
1477
|
+
|
|
1478
|
+
export declare function waitForElementToBeRemoved<T>(
|
|
1479
|
+
callback: T | (() => T),
|
|
1480
|
+
options?: waitForOptions,
|
|
1481
|
+
): Promise<void>
|
|
1482
|
+
|
|
1483
|
+
export declare interface waitForOptions {
|
|
1484
|
+
container?: HTMLElement
|
|
1485
|
+
timeout?: number
|
|
1486
|
+
interval?: number
|
|
1487
|
+
onTimeout?: (error: Error) => Error
|
|
1488
|
+
mutationObserverOptions?: MutationObserverInit
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
/**
|
|
1492
|
+
* Wait for the next event loop.
|
|
1493
|
+
*
|
|
1494
|
+
* It will be useful when you want to wait for the next event loop to finish.
|
|
1495
|
+
*
|
|
1496
|
+
* @public
|
|
1497
|
+
*/
|
|
1498
|
+
export declare function waitSchedule(): Promise<void>;
|
|
1499
|
+
|
|
1500
|
+
export declare const within: typeof getQueriesForElement;
|
|
1501
|
+
|
|
1502
|
+
export declare type WithSuggest = {suggest?: boolean}
|
|
1503
|
+
|
|
1504
|
+
export { }
|