@emotion/ snapshot-序列器
游戏和情感的快照连载器
@emotion/snapshot-serializer提供一种将散列器从情感类中去掉并格式化为情感风格元素的css的快活序列器
安装
yarn add --dev @emotion/snapshot-serializer
开始
/** @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()
})
把它加进你的杰斯配置
也可以将串行器添加到您的游戏配置中,而不是在每次测试中添加.
{
...package.json
"jest": {
"snapshotSerializers": ["@emotion/snapshot-serializer"]
}
}