@griffel/jest-serializer
TypeScript icon, indicating that this package has built-in type declarations

1.1.31 • Public • Published

Jest serializer for Griffel

Provides a Jest serializer for @griffel/react that strips out class names generated by Griffel from the output.

Install

Add it as a dependency:

yarn add --dev @griffel/jest-serializer
# or
npm install --save-dev @griffel/jest-serializer

Update your jest.config.js (or appropriate config location) to include a snapshotSerializers array that references this package:

module.exports = {
  snapshotSerializers: ['@griffel/jest-serializer'],
};

Overview

When using Jest snapshot testing with components that utilize @griffel/react, class names will be rendered as follows:

<div class="static-class __1qdh4ig f16th3vw frdkuqy0 fat0sn40 fjseox00">Hello world</div>

With this serializer, the generated class names will be removed:

<div class="static-class">Hello world</div>

This ensures that your tests can pass reliably without any generated class names.

Readme

Keywords

none

Package Sidebar

Install

npm i @griffel/jest-serializer

Weekly Downloads

614

Version

1.1.31

License

MIT

Unpacked Size

7.95 kB

Total Files

6

Last publish

Collaborators

  • uifabricteam
  • justslone
  • levithomason
  • ling1726
  • miroslavstastny
  • layershifter