jest-serializer-simple
TypeScript icon, indicating that this package has built-in type declarations

5.0.0-0.1 • Public • Published

jest-serializer-simple

GitHub Sponsors Patreon sponsor button Discord chat room Follow

A Jest serializer to simplify your snapshots.

Sometimes you just want to print an object or a string without all the escapes and Object [null prototype] { annotations. When you want that, this is a simple solution for it.

Crowd-funded open-source software

To help us develop this software sustainably under the MIT license, we ask all individuals and businesses that use it to help support its ongoing maintenance and development via sponsorship.

And please give some love to our featured sponsors 🤩:

Surge
Surge
*
Netflix
Netflix
*
Qwick
Qwick
*
The Guild
The Guild
*
Chad Furman
Chad Furman
*
Fanatics
Fanatics
*
Dovetail
Dovetail
*
Enzuzo
Enzuzo
*
Stellate
Stellate
*

* Sponsors the entire Graphile suite

Usage:

yarn add jest-serializer-simple

Then add it to your Jest config:

module.exports = {
  testEnvironment: "node",
  snapshotSerializers: [`jest-serializer-simple`],
  //...
};

To tell Jest that you want the object to be printed simply, you must wrap it in an object with just the __ key: { __: YOUR_VALUE_HERE }, for example:

expect({ __: data }).toMatchInlineSnapshot(`
  {
    forums: [
      {
        name: 'Cats',
      },
      {
        name: 'Dogs',
      },
      {
        name: 'Postgres',
      },
    ],
  }
`);

Package Sidebar

Install

npm i jest-serializer-simple

Weekly Downloads

1

Version

5.0.0-0.1

License

MIT

Unpacked Size

7.16 kB

Total Files

7

Last publish

Collaborators

  • benjie