Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to test aria-expanded attributes

$
0
0

I am writing a test for a simple svelte component. It goes like this:

it('opens and closes correctly', async () => {render(Menubar, { menuData: menu_with_items });const menuButton = screen.getByRole('button', { name: 'menu-item-1' });expect(menuButton).toHaveAttribute('aria-expanded', 'false');fireEvent.click(menuButton);await waitFor(() => expect(menuButton).toHaveAttribute('aria-expanded', 'true'));});

With output:

expect(element).toHaveAttribute("aria-expanded", "true") //element.getAttribute("aria-expanded") === "true" Expected the elementto have attribute: aria-expanded="true" Received:aria-expanded="false"

I tried checking with screen.debug() and the 'aria-expanded' attribute of the element is always equal to false, the component is working accordingly. Am I doing something wrong? Is there another approach?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>