0.8.2 • Published 7 years ago

@emotion/snapshot-serializer v0.8.2

Weekly downloads
1,931
License
MIT
Repository
github
Last release
7 years ago

@emotion/snapshot-serializer

A snapshot serializer for jest and emotion

@emotion/snapshot-serializer provides a jest serializer that removes hashes from emotion classes and formats the css in emotion style elements

Install

yarn add --dev @emotion/snapshot-serializer

Getting started

/** @jsx jsx */
import jsx from '@emotion/jsx'
import renderer from 'react-test-renderer'
import serializer from '@emotion/snapshot-serializer'

expect.addSnapshotSerializer(serializer)

test('style renders correctly', () => {
  expect(
    renderer
      .create(
        <div>
          <div css={{ color: 'hotpink' }}>Some hotpink text</div>
        </div>
      )
      .toJSON()
  ).toMatchSnapshot()
})

Adding it to your Jest config

You can also add the serializer to your jest config instead of adding it in each test.

{
  ...package.json
  "jest": {
    "snapshotSerializers": ["@emotion/snapshot-serializer"]
  }
}
0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago