1 | import { ElementType, ReactElement } from "react";
|
2 | export {};
|
3 |
|
4 | // extracted from:
|
5 | // - https://github.com/facebook/react/blob/v18.0.0/packages/react-test-renderer/index.js
|
6 | // - https://reactjs.org/docs/test-renderer.html
|
7 |
|
8 | /** @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer. */
|
9 | export interface ReactTestRendererJSON {
|
10 | type: string;
|
11 | props: { [propName: string]: any };
|
12 | children: null | ReactTestRendererNode[];
|
13 | }
|
14 | /** @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer. */
|
15 | export type ReactTestRendererNode = ReactTestRendererJSON | string;
|
16 | /** @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer. */
|
17 | export interface ReactTestRendererTree extends ReactTestRendererJSON {
|
18 | nodeType: "component" | "host";
|
19 | instance: any;
|
20 | rendered: null | ReactTestRendererTree | ReactTestRendererTree[];
|
21 | }
|
22 | /** @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer. */
|
23 | export interface ReactTestInstance {
|
24 | instance: any;
|
25 | type: ElementType;
|
26 | props: { [propName: string]: any };
|
27 | parent: null | ReactTestInstance;
|
28 | children: Array<ReactTestInstance | string>;
|
29 |
|
30 | find(predicate: (node: ReactTestInstance) => boolean): ReactTestInstance;
|
31 | findByType(type: ElementType): ReactTestInstance;
|
32 | findByProps(props: { [propName: string]: any }): ReactTestInstance;
|
33 |
|
34 | findAll(predicate: (node: ReactTestInstance) => boolean, options?: { deep: boolean }): ReactTestInstance[];
|
35 | findAllByType(type: ElementType, options?: { deep: boolean }): ReactTestInstance[];
|
36 | findAllByProps(props: { [propName: string]: any }, options?: { deep: boolean }): ReactTestInstance[];
|
37 | }
|
38 | /** @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer. */
|
39 | export interface ReactTestRenderer {
|
40 | toJSON(): null | ReactTestRendererJSON | ReactTestRendererJSON[];
|
41 | toTree(): null | ReactTestRendererTree;
|
42 | unmount(nextElement?: ReactElement): void;
|
43 | update(nextElement: ReactElement): void;
|
44 | getInstance(): null | ReactTestInstance;
|
45 | root: ReactTestInstance;
|
46 | }
|
47 | /** @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer. */
|
48 | export interface TestRendererOptions {
|
49 | createNodeMock(element: ReactElement): any;
|
50 | }
|
51 |
|
52 | /**
|
53 | * @deprecated See https://react.dev/warnings/react-test-renderer
|
54 | */
|
55 | export function create(nextElement: ReactElement, options?: TestRendererOptions): ReactTestRenderer;
|
56 |
|
57 | // VoidOrUndefinedOnly is here to forbid any sneaky "Promise" returns.
|
58 | // the actual return value is always a "DebugPromiseLike".
|
59 | declare const UNDEFINED_VOID_ONLY: unique symbol;
|
60 | // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
61 | type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
|
62 | /**
|
63 | * @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer.
|
64 | * Wrap any code rendering and triggering updates to your components into `act()` calls.
|
65 | *
|
66 | * Ensures that the behavior in your tests matches what happens in the browser
|
67 | * more closely by executing pending `useEffect`s before returning. This also
|
68 | * reduces the amount of re-renders done.
|
69 | *
|
70 | * @param callback An asynchronous, void callback that will execute as a single, complete React commit.
|
71 | *
|
72 | * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
73 | * @deprecated See https://react.dev/warnings/react-test-renderer
|
74 | */
|
75 | // VoidOrUndefinedOnly is here to forbid any sneaky return values
|
76 | export function act(callback: () => Promise<VoidOrUndefinedOnly>): Promise<undefined>;
|
77 | /**
|
78 | * @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer.
|
79 | * Wrap any code rendering and triggering updates to your components into `act()` calls.
|
80 | *
|
81 | * Ensures that the behavior in your tests matches what happens in the browser
|
82 | * more closely by executing pending `useEffect`s before returning. This also
|
83 | * reduces the amount of re-renders done.
|
84 | *
|
85 | * @param callback A synchronous, void callback that will execute as a single, complete React commit.
|
86 | *
|
87 | * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
|
88 | * @deprecated See https://react.dev/warnings/react-test-renderer
|
89 | */
|
90 | export function act(callback: () => VoidOrUndefinedOnly): DebugPromiseLike;
|
91 |
|
92 | // Intentionally doesn't extend PromiseLike<never>.
|
93 | // Ideally this should be as hard to accidentally use as possible.
|
94 | /** @deprecated react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer. */
|
95 | export interface DebugPromiseLike {
|
96 | // the actual then() in here is 1-ary, but that doesn't count as a PromiseLike.
|
97 | then(onfulfilled: (value: never) => never, onrejected: (reason: never) => never): never;
|
98 | }
|