I want to test my components using jest @testing-library/react
and in some tests I need to check the component styles, but because we have .module.scss files,
the styles that are passed through the classes are not assigned
how do i fix this
how do I check/know what styles the components have when checking via jest @testing-library/react
sample code:
menu.test.tsx
test(test, () => {
const { getByTestId } = render(<Menu items={itemsNoIcon} />);
const menu_items = getByTestId('menu__items');
expect(menu_items).toBeInTheDocument();
expect(menu_items).not.toBeVisible();
});
snippet from menu.tsx
<div
data-testid='menu__items'
className={cn(st.menuWrapper, { [st.menuWrapper_open]: isMenuOpened })})}
/>
menu.module.scss snippet
.menuWrapper {
@include shadow('area');
@include transition((opacity, visibility));
border-radius: 4px;
z-index: 1;
padding: 40px 4px 8px 8px 4px;
position: absolute;
display: flex;
flex-direction: column;
background-color: $white;
right: -4px;
top: -5px;
opacity: 0;
visibility: hidden;
cursor: default;
&_open {
opacity: 1;
visibility: visible;
}
}