Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

yurii-sorokin/ngx-jest-snapshot-serializer

Repository files navigation

ngx-jest-snapshot-serializer

npm Build Status codecov

Plugin that serializes Angular fixture components for Jest snapshot tests.

Install

$ npm install --save-dev ngx-jest-snapshot-serializer

Usage

For an individual test file:

import serializer from 'ngx-jest-snapshot-serializer';
expect.addSnapshotSerializer(serializer);

For all test files, you need to specify serializer in Jest configuration. For example, in a package.json file:

{
  "jest": {
    "snapshotSerializers": ["ngx-jest-snapshot-serializer"]
  }
}

If you do not set up jest testing in your Angular application yet then look at this preset.

Example

Example snapshot outputs could be found in the examples/ directory.

Further reading

More details about snapshot plugins could be found in Pretty format package.


Highly inspired by enzyme-to-json package.