Запуск библиотеки тестирования React для создания снимков на JSX, который использует опору Emotion css, приводит к тому, что CSS не отображается.
Я пробовал использовать @motion / jest / serializer, но все равно не повезло.
Компонент:
<button
role="button"
css={(theme)=> {
backgroundColor: 'hotpink',
'&:hover': {
color: theme('lightgreen'),
},
}}
/>
Тест:
import React from 'react';
import { render } from '@testing-library/react';
import { createSerializer } from '@emotion/jest';
import { Component } from './component';
expect.addSnapshotSerializer(createSerializer());
describe('IconComponent', () => {
it('should match the snapshot for the given props', () => {
const { asFragment } = render(<Component icon="knownIcon" />);
expect(asFragment()).toMatchSnapshot();
});
Снимок: (отображается как анонимный объект, а не CSS)
exports[` 1`] = `
<DocumentFragment>
<button
css="[object Object]"
role="button"
/>
</DocumentFragment>
`;