Note: This is a fork of jest-styled-components that has been adapted to work with vitest.
A set of utilities for testing Styled Components with vitest. This package improves the snapshot testing experience and provides a brand new matcher to make expectations on the style rules.
yarn add --dev @mirakl/vitest-styled-componentsIn your vitest setup file, you can add the following:
import { toHaveStyleRule, resetStyleSheet, styleSheetSerializer } from '@mirakl/vitest-styled-components';
beforeEach(() => {
resetStyleSheet();
});
expect.addSnapshotSerializer(styleSheetSerializer);
expect.extend({ toHaveStyleRule });yarn buildThis will build the package for both CommonJS and ES Modules.
Check the build output with:
yarn verify-build