import type { StyleProp } from 'react-native'; import type { TestInstance } from 'test-renderer'; import type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value'; import type { TextMatch, TextMatchOptions } from '../matches'; import type { Style } from './to-have-style'; export interface JestNativeMatchers { /** * Assert whether a host element is present in the element tree (screen) or not. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeonthescreen) * * @example * Hello * * expect(getByText('Hello')).toBeOnTheScreen() * expect(queryByText('Other')).not.toBeOnTheScreen() */ toBeOnTheScreen(): R; /** * Assert whether a host element is checked based on accessibility props. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobechecked) * * @see {@link toBePartiallyChecked} for a related matcher. * * @example * * * expect(getByRole('checkbox', { name: "Enable" })).toBeChecked() */ toBeChecked(): R; /** * Assert whether a host element is collapsed based on accessibility props. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeexpanded) * * @see {@link toBeExpanded} for an inverse matcher. * * @example * * * expect(getByTestId('details').toBeCollapsed() */ toBeCollapsed(): R; /** * Assert whether a host element is disabled based on accessibility props. * * This matcher will check ancestor elements for their disabled state as well. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeenabled) * * @see {@link toBeEnabled} for an inverse matcher. * * @example * * * expect(getByRole('button').toBeDisabled() * */ toBeDisabled(): R; /** * Assert whether a host element is busy based on accessibility props. * * This matcher will check ancestor elements for their disabled state as well. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobebusy) * * @example * * * expect(getByTestId('loader')).toBeBusy() */ toBeBusy(): R; /** * Assert whether a host element has no host children or text content. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeemptyelement) * * @example * * * * * expect(getByTestId('empty')).toBeEmptyElement() * expect(getByTestId('not-mepty')).not.toBeEmptyElement() */ toBeEmptyElement(): R; /** * Assert whether a host element is enabled based on accessibility props. * * This matcher will check ancestor elements for their disabled state as well. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeenabled) * * @see {@link toBeDisabled} for inverse matcher. * * @example * * * expect(getByRole('button').toBeEnabled() */ toBeEnabled(): R; /** * Assert whether a host element is expanded based on accessibility props. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeexpanded) * * @see {@link toBeCollapsed} for inverse matcher. * * @example * * * expect(getByTestId('details').toBeExpanded() */ toBeExpanded(): R; /** * Assert whether a host element is partially checked based on accessibility props. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobechecked) * * @see {@link toBeChecked} for related matcher. * * @example * * * expect(getByRole('checkbox', { name: "Enable" })).toBePartiallyChecked() */ toBePartiallyChecked(): R; /** * Assert whether a host element is selected based on accessibility props. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeselected) * * @example * * * expect(getByTestId('view')).toBeSelected() */ toBeSelected(): R; /** * Assert whether a host element is visible based on style and accessibility props. * * This matcher will check ancestor elements for their visibility as well. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobevisible) * * @example * * * * expect(getByTestId('visible')).toBeVisible() * expect(getByTestId('not-visible')).not.toBeVisible() */ toBeVisible(): R; /** * Assert whether a host element contains another host element. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tocontainelement) * * @example * * * * * expect(getByTestId('outer')).toContainElement(getByTestId('inner')); */ toContainElement(instance: TestInstance | null): R; /** * Assert whether a host element has a given accessbility value. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveaccessibilityvalue) * * * @example * * * expect(getByTestId('view')).toHaveAccessibilityValue({ text: '33%' }); */ toHaveAccessibilityValue(expectedValue: AccessibilityValueMatcher): R; /** * Assert whether a host element has a given accessibile name based on the accessibility label or text content. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveaccessiblename) * * @example * * * expect(getByTestId('view')).toHaveAccessibleName('Hello'); */ toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R; /** * Assert whether a host `TextInput` element has a given display value based on `value` prop, unmanaged native state, and `defaultValue` prop. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohavedisplayvalue) * * @example * * * expect(getByTestId('input')).toHaveDisplayValue('Hello'); */ toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R; /** * Assert whether a host element has a given prop. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveprop) * * @example * * * expect(getByTestId('text')).toHaveProp('numberOfLines'); * expect(getByTestId('text')).toHaveProp('numberOfLines', 1); */ toHaveProp(name: string, expectedValue?: unknown): R; /** * Assert whether a host element has a given style. * * @see * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohavestyle) * * @example * * * expect(getByTestId('view')).toHaveStyle({ width: '100%' }); * expect(getByTestId('view')).not.toHaveStyle({ width: '50%' }); */ toHaveStyle(style: StyleProp