jest-serializer-json-date-id-mask

2.0.0 • Public • Published

Serializer for Objects that include volatile dates and IDS

This is useful for example when testing with a DB that generates IDs and Dates

The serializer will look for columns marked as ID or Date and mask them, as these will normally change from test to test.

Please note that this will be incompatible with react projects, so if you are testing other objects use Expect.addSerializer to restrict to only one test suite.

Usage

You need to add the snapshot serializer. You have two options:

  1. Expect.addSerializer
const jsonDateIdMask = require('jest-serializer-json-date-id-mask');
expect.addSnapshotSerializer(jsonDateIdMask);
  1. Jest config

for example in package.json

{
  "name": "my project",
  "jest": {
    "snapshotSerializers": ["jest-serializer-json-date-id-mask"]
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i jest-serializer-json-date-id-mask

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

2.3 kB

Total Files

3

Last publish

Collaborators

  • jwickens