File size: 2,577 Bytes
bc20498 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
/// <reference types="cypress" />
/// <reference types="cypress" />
import React__default from 'react';
import * as react_dom from 'react-dom';
/**
* Gets the root element used to mount the component.
* @returns {HTMLElement} The root element
* @throws {Error} If the root element is not found
*/
declare const getContainerEl: () => HTMLElement;
interface UnmountArgs {
log: boolean;
boundComponentMessage?: string;
}
declare type MountOptions = Partial<MountReactComponentOptions>;
interface MountReactComponentOptions {
ReactDom: typeof react_dom;
/**
* Log the mounting command into Cypress Command Log,
* true by default.
*/
log: boolean;
/**
* Render component in React [strict mode](https://reactjs.org/docs/strict-mode.html)
* It activates additional checks and warnings for child components.
*/
strict: boolean;
}
interface MountReturn {
/**
* The component that was rendered.
*/
component: React__default.ReactNode;
/**
* Rerenders the specified component with new props. This allows testing of components that store state (`setState`)
* or have asynchronous updates (`useEffect`, `useLayoutEffect`).
*/
rerender: (component: React__default.ReactNode) => globalThis.Cypress.Chainable<MountReturn>;
/**
* Removes the mounted component.
*
* Removed as of Cypress 11.0.0.
* @see https://on.cypress.io/migration-11-0-0-component-testing-updates
*/
unmount: (payload: UnmountArgs) => void;
}
/**
* Mounts a React component into the DOM.
* @param {import('react').JSX.Element} jsx The React component to mount.
* @param {MountOptions} options Options to pass to the mount function.
* @param {string} rerenderKey A key to use to force a rerender.
*
* @example
* import { mount } from '@cypress/react'
* import { Stepper } from './Stepper'
*
* it('mounts', () => {
* mount(<StepperComponent />)
* cy.get('[data-cy=increment]').click()
* cy.get('[data-cy=counter]').should('have.text', '1')
* }
*
* @see {@link https://on.cypress.io/mounting-react} for more details.
*
* @returns {Cypress.Chainable<MountReturn>} The mounted component.
*/
declare function mount(jsx: React__default.ReactNode, options?: MountOptions, rerenderKey?: string): Cypress.Chainable<MountReturn>;
/**
* Removed as of Cypress 11.0.0.
* @see https://on.cypress.io/migration-11-0-0-component-testing-updates
*/
declare function unmount(options?: UnmountArgs): void;
export { MountOptions, MountReturn, getContainerEl, mount, unmount };
|