1.0.0 • Published 2 years ago
jest-strip-styled-components v1.0.0
Jest Strip Styled Components
A serializer for Jest snapshot testing to remove Styled Components classes from your code.
Quick Start
Installation
yarn add --dev jest-strip-styled-components
Usage
The serializer can be imported separately from jest-strip-styled-components
.
This makes it possible to use this package with specific-snapshot and other libraries.
import React from 'react'
import styled from 'styled-components'
import renderer from 'react-test-renderer'
import { stripSCSerializer } from "jest-strip-styled-components"
import { addSerializer } from "jest-specific-snapshot"
addSerializer(stripSCSerializer)
const Button = styled.button`
color: red;
`
test('it works', () => {
const tree = renderer.create(<Button />).toJSON()
expect(tree).toMatchSpecificSnapshot("./Button.snap")
})
1.0.0
2 years ago