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

0.6.0 • Public • Published

Jest Snapshot Serializer

Format Machinat JSX elements in the jest snapshot.

Install

npm install @machinat/jest-snapshot-serializer
# or with yarn
yarn add @machinat/jest-snapshot-serializer

Setup

Add the serializer to into jest.config.js:

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

Or packages.json:

{
  "name": "my-project",
  "jest": {
    "snapshotSerializers": ["@machinat/jest-snapshot-serializer"],
  }
}

Example

expect(
  <GenericTemplate imageAspectRatio="square" sharable>
    <GenericItem
      title="foo"
      imageUrl="http://foo.bar/image"
      buttons={<UrlButton title="check" url="http://xxx.yy.z" />}
    />
  </GenericTemplate>
).toMatchInlineSnapshot(`
  <GenericTemplate
    imageAspectRatio="square"
    sharable={true}
  >
    <GenericItem
      buttons={
        <UrlButton
          title="check"
          url="http://xxx.yy.z"
        />
      }
      imageUrl="http://foo.bar/image"
      title="foo"
    />
  </GenericTemplate>
`);

Readme

Keywords

none

Package Sidebar

Install

npm i @machinat/jest-snapshot-serializer

Weekly Downloads

1

Version

0.6.0

License

MIT

Unpacked Size

4.79 kB

Total Files

6

Last publish

Collaborators

  • lrills0515
  • lrills