Skip to content

Latest commit

 

History

History

kbn-jest-serializers

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
id slug title description date tags
kibDevDocsOpsJestSerializers
/kibana-dev-docs/ops/jest-serializers
@kbn/jest-serializers
A set of shared serializers to help on writing jest tests
2022-05-17
kibana
dev
contributor
operations
jest
serializers

This package holds a set of shared serializers that may be useful when you're writing jest tests. To use them import the package and call one of the functions, passing the result to expect.addSnapshotSerializer().

createAbsolutePathSerializer

Replaces a given path starting a string with the provided replacer. Additionally also replaces any \\ with / it founds.

createStripAnsiSerializer

Strips ansi from a string.

createRecursiveSerializer

It helps on printing recursive nodes.

createAnyInstanceSerializer

It serializes any kind of instance inside <>. If it is a function calls the function inside the node otherwise prints as Class.name.

createReplaceSerializer

Search for a substring using given Regex or string and replaces with a provided replacer.

Example

import { createAbsolutePathSerializer } from '@kbn/jest-serializers'

expect.addSnapshotSerializer(createAbsolutePathSerializer());