Equality comparison

June 03, 20201 minute read

The eq check compares every element in an object irrespective of the order of object keys and array elements. Every element in the compared object should match the object element defined in the eq block. The accepted value is either an object or an array.

Syntax

{
  ...
  "expect": {
    "body": {
      "eq": {
        "key": "value"
      },
    "header": {
      "eq": {
        "key": "value"
      }
    }
  }
}

Example

The API has the following response.

{
  "name": "ram",
  "age": 20
}

To test using eq check:

{
  ...
  "expect": {
    "body": {
      "eq": {
        "name": "ram",
        "age": 20
      }
    }
  }
}

The check will pass for the above response. If any of the value or key is different it will throw an error.

General use cases

  • Testing the contents of the response if it is static and predictable.
  • Ideal case for error message checking.