jest-strip-styled-components

1.0.0 • Public • Published

NPM version

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")
})

Package Sidebar

Install

npm i jest-strip-styled-components

Weekly Downloads

10

Version

1.0.0

License

MIT

Unpacked Size

16.8 kB

Total Files

7

Last publish

Collaborators

  • jasperrr91