Type alias AccessorParamsBaseType

AccessorParamsBaseType: Readonly<{
    mapper?: ((targetElement) => HTMLElement);
    parent?: AccessorParamsType;
}>

Type declaration

  • Optional mapper?: ((targetElement) => HTMLElement)
      • (targetElement): HTMLElement
      • Function for get needed element by target element. For example, get input by label in cluttered layout

        Parameters

        • targetElement: HTMLElement

          element that found by query and parameters

        Returns HTMLElement

        element that will be a result of calling the method of accessor

        Example for Radio from antd@5.10.1

        const render = create(Component, defaultProps, {
        queries: {
        radio: {
        query: AccessorQueryType.Text,
        parameters: ["Radio"],
        mapper: (radioLabel) => {
        const wrapper = radioLabel.closest(".ant-radio-wrapper");

        if (!wrapper) {
        throw new Error("radio wrapper is not found");
        }

        const input = wrapper.querySelector("input");

        if (!input) {
        throw new Error("radio input is not found");
        }

        return input as HTMLElement;
        },
        },
        },
        });

        const engine = render({});

        const radioInput = page.accessors.radio.get();
  • Optional parent?: AccessorParamsType

    Accessor of the parent element, can be used for same elements, e.g. lists of snippets, rows of tables

Generated using TypeDoc