1.0.0 • Published 6 years ago

jest-string-object-serializer v1.0.0

Weekly downloads
17
License
Apache-2.0
Repository
github
Last release
6 years ago

jest-string-object-serializer

A jest snapshot serializer for String objects.

Motivation

Made for when you have a String object passed to React props that you want to serialize. E.g., <div className={new String('val')} /> will have a weird snaphsot output by default, that would be fixed by simply calling toString() on the String object. Which is exactly what jest-string-object-serializer does.

Usage

  1. Install
npm install --save-dev jest-string-object-serializer
# Or yarn add --dev jest-string-object-serializer
  1. jest.json configuration
{
  "snapshotSerializers": [
    "<rootDir>/node_modules/jest-string-object-serializer/lib/serializer"
  ],
}

If you're using react and enzyme, you probably should also add "<rootDir>/node_modules/enzyme-to-json/serializer" as a snapshot serializer to get the react snapshots to look right.