1 | export type Hook = (...args: any[]) => void | Promise<void>;
|
2 | export type HookLabel = 'start' | 'end' | 'targetFound';
|
3 | export type HookUnregister = {
|
4 | unregister: () => void;
|
5 | };
|
6 | /**
|
7 | * Registers a function to be run during the invocation of a test helper.
|
8 | *
|
9 | * @param {string} helperName The name of the test helper in which to run the hook.
|
10 | * Test helper names include `blur`, `click`, `doubleClick`, `fillIn`,
|
11 | * `fireEvent`, `focus`, `render`, `scrollTo`, `select`, `tab`, `tap`, `triggerEvent`,
|
12 | * `triggerKeyEvent`, `typeIn`, and `visit`.
|
13 | * @param {string} label A label to help identify the hook. Built-in labels include `start`, `end`,
|
14 | * and `targetFound`, the former designating either the start or end of
|
15 | * the helper invocation.
|
16 | * @param {Function} hook The hook function to run when the test helper is invoked.
|
17 | * @returns {HookUnregister} An object containing an `unregister` function that unregisters
|
18 | * the specific hook initially registered to the helper.
|
19 | * @example
|
20 | * <caption>
|
21 | * Registering a hook for the `end` point of the `click` test helper invocation
|
22 | * </caption>
|
23 | *
|
24 | * const hook = registerHook('click', 'end', () => {
|
25 | * console.log('Running `click:end` test helper hook');
|
26 | * });
|
27 | *
|
28 | * // Unregister the hook at some later point in time
|
29 | * hook.unregister();
|
30 | */
|
31 | export declare function registerHook(helperName: string, label: HookLabel, hook: Hook): HookUnregister;
|
32 | /**
|
33 | * Runs all hooks registered for a specific test helper.
|
34 | *
|
35 | * @param {string} helperName The name of the test helper in which to run the hook.
|
36 | * Test helper names include `blur`, `click`, `doubleClick`, `fillIn`,
|
37 | * `fireEvent`, `focus`, `render`, `scrollTo`, `select`, `tab`, `tap`, `triggerEvent`,
|
38 | * `triggerKeyEvent`, `typeIn`, and `visit`.
|
39 | * @param {string} label A label to help identify the hook. Built-in labels include `start`, `end`,
|
40 | * and `targetFound`, the former designating either the start or end of
|
41 | * the helper invocation.
|
42 | * @param {unknown[]} args Any arguments originally passed to the test helper.
|
43 | * @returns {Promise<void>} A promise representing the serial invocation of the hooks.
|
44 | */
|
45 | export declare function runHooks(helperName: string, label: HookLabel, ...args: unknown[]): Promise<void>;
|
46 | //# sourceMappingURL=helper-hooks.d.ts.map |
\ | No newline at end of file |