import { screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; export const selectOption = async (selectElement: HTMLElement | null, value: string) => { if (!selectElement) { throw new Error('Не найден элемент выпадающего списка'); } const bankcardDropdown = within(selectElement).getByRole('combobox'); await userEvent.click(bankcardDropdown); const option = screen.getAllByRole('option').find((el) => el.dataset.value === value); if (!option) { throw new Error(`Не найдена опция с value:${value}`); } await userEvent.click(option); };