I'm trying to use jest with styled components to test a component's styles, and I'm having the error:
Syntax error parsing expected css: missing '}' here
Failing css:
[object Object]
My component is a simple link with styled-components:
import styled from 'styled-components'
export const Link = styled.a`
color: #fff;
`
My test:
describe('Link', () => {
it('should display color on the link', () => {
render(<Link href="/x">Test</Link>)
}
expect(screen.getByRole('link', { name: /test/i })).toHaveStyle({ color: '#fff' })
}
I'm running the npm react-scripts test.
I've tried to import 'jest-styled-components' and '@testing-library/jest-dom'