jest-snapshot-delete-properties
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Delete properties from snapshot

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

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>
`;

Package Sidebar

Install

npm i jest-snapshot-delete-properties

Weekly Downloads

4

Version

0.0.1

License

MIT

Unpacked Size

13.8 kB

Total Files

24

Last publish

Collaborators

  • neotan