UNPKG

webdriverio

Version:

Next-gen browser and mobile automation test framework for Node.js

56 lines • 2.23 kB
/** * React component queries for `react$` and `react$$`. The compiler bundles this * file into `WDIO_REACT_SCRIPT`, which the commands inject into the page. * * The fiber lookup reads the root of the tree from a DOM node and takes `current` * of that root, so that a query sees the current render: React keeps two copies of * each fiber and uses the other copy after each update (#15879). * * The query rules are the rules of resq 1.11, which these commands used before, so * that a selector finds the same components: * - a selector is a list of component names separated by spaces, each one a * descendant of the one before; `*` matches one or more characters; * - the name of a higher-order component `withX(Name)` is `Name`; * - `props` and `state` match when each key that the component also has matches, * and a nested object matches the same way. * One difference: `react$` applies both `props` and `state`. resq ignored `props` * when `state` was also given. * * The code reads React internals that are the same from React 16 to 19: the * `HostRoot` tag (`3`), `stateNode.current`, `return`, `child`, `sibling`, * `memoizedProps`, `memoizedState`, and the `__reactFiber$`, * `__reactInternalInstance$`, `__reactContainer$` and `_reactRootContainer` keys. * The wait also reads `alternate` and `pendingLanes` of the root (React 17 and * later). */ type HostNode = HTMLElement | Text; /** * the fields of a React fiber that this script reads */ export interface Fiber { tag: number; type?: unknown; stateNode?: any; return?: Fiber | null; alternate?: Fiber | null; child?: Fiber | null; sibling?: Fiber | null; memoizedProps?: unknown; memoizedState?: unknown; } export interface ReactNode { name?: unknown; props?: unknown; state?: unknown; children: ReactNode[]; node?: HostNode | HostNode[] | null; isFragment?: boolean; } export interface ReactQueryApi { findRoots: () => Fiber[]; findFiber: (scope: HTMLElement) => Fiber | undefined; isRendered: (root?: Fiber) => boolean; query: (selector: string, props: unknown, state: unknown, fiber: Fiber) => ReactNode[]; } export {}; //# sourceMappingURL=react.d.ts.map