Skip to content

Instantly share code, notes, and snippets.

@IgorGee
Last active March 14, 2017 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorGee/58db781515c90784bb25796123d6664b to your computer and use it in GitHub Desktop.
Save IgorGee/58db781515c90784bb25796123d6664b to your computer and use it in GitHub Desktop.
Attempting to unit test with styled components
// Title.js
import styled from 'styled-components'
const Title = styled.h1`
text-align: center;
color: green;
`
// Home.js
import Title from 'components/Title'
const Home = () => (
<div>
<Title>Home</Title>
</div>
)
// Home.test.js
describe('<Home />', () => {
let wrapper
beforeEach(() => {
wrapper = shallow(<Home />)
})
describe('User Interface', () => {
it('has a Title displaying Home', () => {
const title = wrapper.find('Title') // Finds 0 nodes
console.log(title.debug()) // Nothing
expect(title.text()).toEqual('Home') // The api I was expecting to work
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment