#reactjs #unit-testing #jestjs #enzyme #emotion
Вопрос:
У меня есть следующий компонент:
import styled from 'react-emotion';
import { lighten } from 'polished';
import { unit, colors } from '../styles';
const Button = styled('button')({
display: 'block',
minWidth: 200,
height: '20px',
margin: '0 auto',
border: 'none',
});
export default Button
Я хочу протестировать его на ферменте
, и я попробовал следующее:
// Add the custom matchers provided by '@emotion/jest'
expect.extend(matchers)
describe('Button', () => {
afterEach(cleanup);
it('renders without error', () => {
const comp= shallow(<Button />)
console.log(comp.debug())
expect(comp.find('button')).toHaveStyleRule('color', "white")
});
});
но это не работает, и я думаю, что css компонента не доступен в тесте.
кто-нибудь знает, что не так?