0.0.1 • Published 4 years ago

jest-snapshot-delete-properties v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Delete properties from snapshot

Use this serializer to remove any unwanted properties from snapshot, keeping it sparkling clean :sparkles:

Install

Add the package as a dev dependency

# With npm
npm install --save-dev jest-snapshot-delete-properties

# With yarn
yarn add --dev jest-snapshot-delete-properties

Register serializer with Jest in your setupTests.js:

import snapshotDeleteProperties from "jest-snapshot-delete-properties";

expect.addSnapshotSerializer(snapshotDeleteProperties(["want-to-delete-attr1", "want-to-delete-attr2"]));

Vanilla JS Example

test('should remove data attributes', () => {
  expect(<Component want-to-delete-attr1="bye" id="keep-me">Children</Component>).toMatchSnapshot();
});

Will output:

exports[`should remove data attributes`] = `
<div
  id="keep-me"
>
  Children
</div>
`;