Skip to main content

Case matchers

Case matchers are used for the mock server to match the request context.

We use the same naming as the Jest Asymmetric Matchers and almost have the same behavior.

anything()

anything() matches anything but null.

case
{
"body": {
"name": "{{anything()}}"
}
}

any(type)

any(type) matches anything that is the given type.

type includes: Number, String, Array, Object

case
{
"body": {
"id": "{{any(Number)}}",
"name": "{{any(String)}}",
"accesses": "{{any(Array)}}"
}
}

arrayContaining(array)

arrayContaining(array) matches a received array which contains all of the elements in the expected array.

case
{
"body": {
"categories": "{{arrayContaining([1, 2])}}"
}
}

To Continue...