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 |
|
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()
.
Replaces a given path starting a string with the provided replacer. Additionally also replaces any \\
with /
it founds.
Strips ansi from a string.
It helps on printing recursive nodes.
It serializes any kind of instance inside <>
. If it is a function calls the function inside the node otherwise prints as Class.name
.
Search for a substring using given Regex or string and replaces with a provided replacer.
import { createAbsolutePathSerializer } from '@kbn/jest-serializers'
expect.addSnapshotSerializer(createAbsolutePathSerializer());