UNPKG

chakra-ui-select

Version:
70 lines (69 loc) 2.2 kB
import React from 'react'; import { render as rtlRender, RenderOptions, RenderResult } from '@testing-library/react'; import { RunOptions } from 'axe-core'; declare type UI = Parameters<typeof rtlRender>[0]; declare function ChildrenPassthrough({ children }: { children: React.ReactElement; }): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>; export interface TestOptions extends Omit<RenderOptions, 'wrapper'> { /** * optional additional wrapper, e.g. Context * * @example * ```ts * // single wrapper * render(<MyConponent />, { * wrapper: MyContext * }); * * // multiple wrapper * render(<MyConponent />, { * wrapper: ({ children }) => ( * <ContextA> * <ContextB> * {children} * <ContextB /> * <ContextA /> * ) * }); * * ``` */ wrapper?: typeof ChildrenPassthrough; } /** * Custom render for @testing-library/react * * @see https://testing-library.com/docs/react-testing-library/setup#custom-render * @param component the component under test * @param options customized test options */ export declare const render: (ui: UI, { wrapper: Wrapper, ...options }?: TestOptions) => RenderResult; declare type TestA11YOptions = TestOptions & { axeOptions?: RunOptions; }; /** * Validates against common a11y mistakes. * * Wrapper for jest-axe * * @example * ```jsx * it('passes a11y test', async () => { * await testA11Y(<MyComponent />, options); * }); * * // sometimes we need to perform interactions first to render conditional UI * it('passes a11y test when open', async () => { * const { container } = render(<MyComponent />, options); * * fireEvent.click(screen.getByRole('button')); * * await testA11Y(container, options); * }); * ``` * * @see https://github.com/nickcolley/jest-axe#testing-react-with-react-testing-library */ export declare const testA11y: (ui: UI | Element, { axeOptions, ...options }?: TestA11YOptions) => Promise<void>; export {};