UNPKG

4.08 kBTypeScriptView Raw
1import type { keyboardKey } from './system/keyboard';
2import type { pointerKey } from './system/pointer';
3export declare enum PointerEventsCheckLevel {
4 /**
5 * Check pointer events on every user interaction that triggers a bunch of events.
6 * E.g. once for releasing a mouse button even though this triggers `pointerup`, `mouseup`, `click`, etc...
7 */
8 EachTrigger = 4,
9 /** Check each target once per call to pointer (related) API */
10 EachApiCall = 2,
11 /** Check each event target once */
12 EachTarget = 1,
13 /** No pointer events check */
14 Never = 0
15}
16export interface Options {
17 /**
18 * When using `userEvent.upload`, automatically discard files
19 * that don't match an `accept` property if it exists.
20 *
21 * @default true
22 */
23 applyAccept?: boolean;
24 /**
25 * We intend to automatically apply modifier keys for printable characters in the future.
26 * I.e. `A` implying `{Shift>}a{/Shift}` if caps lock is not active.
27 *
28 * This options allows you to opt out of this change in foresight.
29 * The feature therefore will not constitute a breaking change.
30 *
31 * @default true
32 */
33 autoModify?: boolean;
34 /**
35 * Between some subsequent inputs like typing a series of characters
36 * the code execution is delayed per `setTimeout` for (at least) `delay` seconds.
37 * This moves the next changes at least to next macro task
38 * and allows other (asynchronous) code to run between events.
39 *
40 * `null` prevents `setTimeout` from being called.
41 *
42 * @default 0
43 */
44 delay?: number | null;
45 /**
46 * The document.
47 *
48 * This defaults to the owner document of an element if an API is called directly with an element and without setup.
49 * Otherwise it falls back to the global document.
50 *
51 * @default element.ownerDocument??globalThis.document
52 */
53 document?: Document;
54 /**
55 * An array of keyboard keys the keyboard device consists of.
56 *
57 * This allows to plug in different layouts / localizations.
58 *
59 * Defaults to a "standard" US-104-QWERTY keyboard.
60 */
61 keyboardMap?: keyboardKey[];
62 /**
63 * An array of available pointer keys.
64 *
65 * This allows to plug in different pointer devices.
66 */
67 pointerMap?: pointerKey[];
68 /**
69 * The pointer API includes a check if an element has or inherits `pointer-events: none`.
70 * This check is known to be expensive and very expensive when checking deeply nested nodes.
71 * This option determines how often the pointer related APIs perform the check.
72 *
73 * This is a binary flag option. You can combine multiple Levels.
74 *
75 * @default PointerEventsCheckLevel.EachCall
76 */
77 pointerEventsCheck?: PointerEventsCheckLevel | number;
78 /**
79 * `userEvent.type` automatically releases any keys still pressed at the end of the call.
80 * This option allows to opt out of this feature.
81 *
82 * @default false
83 */
84 skipAutoClose?: boolean;
85 /**
86 * `userEvent.type` implies a click at the end of the element content/value.
87 * This option allows to opt out of this feature.
88 *
89 * @default false
90 */
91 skipClick?: boolean;
92 /**
93 * `userEvent.click` implies moving the cursor to the target element first.
94 * This options allows to opt out of this feature.
95 *
96 * @default false
97 */
98 skipHover?: boolean;
99 /**
100 * Write selected data to Clipboard API when a `cut` or `copy` is triggered.
101 *
102 * The Clipboard API is usually not available to test code.
103 * Our `setup` replaces the `navigator.clipboard` property with a stub.
104 *
105 * Defaults to `false` when calling the APIs directly.
106 * Defaults to `true` when calling the APIs per `setup`.
107 */
108 writeToClipboard?: boolean;
109 /**
110 * A function to be called internally to advance your fake timers (if applicable)
111 *
112 * @example jest.advanceTimersByTime
113 */
114 advanceTimers?: ((delay: number) => Promise<void>) | ((delay: number) => void);
115}
116
\No newline at end of file