How to use the @testing-library/dom.findByText function in @testing-library/dom

To help you get started, we’ve selected a few @testing-library/dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github romgain / react-select-event / src / index.ts View on Github external
export const select = async (
  input: HTMLElement,
  optionOrOptions: string | RegExp | Array,
  config: Config = {}
) => {
  const options = Array.isArray(optionOrOptions)
    ? optionOrOptions
    : [optionOrOptions];
  const container = config.container || getReactSelectContainerFromInput(input);

  // Select the items we care about
  for (const option of options) {
    focus(input);

    // only consider accessible elements
    const optionElement = await findByText(container, option, {
      // @ts-ignore invalid rtl types :'(
      ignore: ":not([tabindex])"
    });
    fireEvent.click(optionElement);
  }
};
github gitlabhq / gitlabhq / spec / frontend / __helpers__ / wait_for_text.js View on Github external
export const waitForText = async (text, container = document) => findByText(container, text);
github romgain / react-select-event / src / index.ts View on Github external
export const create = async (
  input: HTMLElement,
  option: string,
  config: CreateConfig = {}
) => {
  const createOptionText = config.createOptionText || /^Create "/;
  focus(input);
  type(input, option);

  fireEvent.change(input, { target: { value: option } });
  await select(input, createOptionText, config);

  await findByText(getReactSelectContainerFromInput(input), option);
};
github gitlabhq / gitlabhq / spec / frontend_integration / ide / helpers / ide_helper.js View on Github external
export const waitForTabToOpen = (fileName) =>
  findByText(document.querySelector('.multi-file-edit-pane'), fileName);