I am using Material UI tabs in my application and using react testing library. I need to write test cases which for navigating from one tab to another one. Can anybody help me with this, since the code below is not properly working. Thanks in advance.
Code:
const [value, setValue] = React.useState(0)
function handleChange(event, newValue) {
setValue(newValue)
}
<AntTabs value={value} onChange={handleChange} aria-label="Unit information">
<AntTab label="HELLOW1" {...unitTabProps(0)} />
<AntTab label="HELLOW2" {...unitTabProps(1)} />
<AntTab label="HELLOW3" {...unitTabProps(2)} />
<AntTab label="HELLOW4" {...unitTabProps(3)} />
<AntTab label="HELLOW5" {...unitTabProps(4)} />
</AntTabs>
expect(screen.getByRole('tab', { selected: true })).toHaveAccessibleName('Tab 2');
– Ingrain