Here is my test code.
It's important to use await and wait for the menu to appear.
MyDropdown.tsx
import React from 'react'
import { Menu, Dropdown, Button } from 'antd';
const menu = (
<Menu data-testid="dropdown-menu">
<Menu.Item>
<a target="_blank" rel="noopener noreferrer" href="http://www.alipay.com/">
1st menu item
</a>
</Menu.Item>
<Menu.Item>
<a target="_blank" rel="noopener noreferrer" href="http://www.taobao.com/">
2nd menu item
</a>
</Menu.Item>
<Menu.Item>
<a target="_blank" rel="noopener noreferrer" href="http://www.tmall.com/">
3rd menu item
</a>
</Menu.Item>
</Menu>
);
export const MyDropdown: React.FC = () => {
return(
<Dropdown overlay={menu} placement="bottomLeft" arrow>
<Button>bottomLeft</Button>
</Dropdown>
)
}
MyDropdown.test.tsx
import React from "react";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import { MyDropdown } from "./MyDropdown";
describe("<MyDropdown />", () => {
it("check dropdown menu item", async () => {
render(<MyDropdown />);
fireEvent.mouseOver(screen.getByText('bottomLeft'));
await waitFor(() => screen.getByTestId('dropdown-menu'))
expect(screen.getByText('1st menu item')).toBeInTheDocument()
expect(screen.getByText('2nd menu item')).toBeInTheDocument()
expect(screen.getByText('3rd menu item')).toBeInTheDocument()
});
});