1.0.0 • Published 6 years ago
jest-string-object-serializer v1.0.0
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
- Install
npm install --save-dev jest-string-object-serializer
# Or yarn add --dev jest-string-object-serializer
- 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.
1.0.0
6 years ago