I want to test antd autocomplete by just ensure, that when user typing something dropdown values will be appearing after fetching data from BE.
And I'm trying to simulate it:
it('user got results while typing something', async () => {
const { getByTestId } = render(<AutoComplete />);
const searchInput = getByTestId('autosuggest-trigger')
.querySelector('.ant-select-selection-search-input');
fireEvent.focus(searchInput);
fireEvent.change(searchInput, { target: { value: 'Alice' } });
expect(searchInput.value).toBe('Alice'); // All is good so far..
await waitFor(() => {
expect(
document.querySelector('.ant-select-dropdown'),
).not.toBeNull(); // FAILS
});
});
I'm getting results BTW in my real app, but can't do a such trick in testing.
What is wrong and how can I solve it?