# Need more help on Snapshot testing in Postman

**URL:** <https://community.postman.com/t/need-more-help-on-snapshot-testing-in-postman/33791>\
**Category:** Help Hub\
**Created:** [March 23, 2022, 11:28pm UTC](https://community.postman.com/t/need-more-help-on-snapshot-testing-in-postman/33791 "2022-03-23T23:28:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rnfasoliz](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rnfasoliz](https://community.postman.com/u/rnfasoliz)\
**Post date:** [March 23, 2022, 11:28pm UTC](https://community.postman.com/t/need-more-help-on-snapshot-testing-in-postman/33791/1 "2022-03-23T23:28:45Z")

</div>

_My question_: I can’t get snapshot testing to work for me. I’ve taken the snapshot response, I’ve created a mock server with that response. What should my test script look like? Is there a pre-requisite step?

_I’ve already tried_: I’ve gone to the topic [Snapshot testing for APIs using Postman](https://community.postman.com/t/snapshot-testing-for-apis-using-postman/4125) but could not understand what their test script included.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [March 24, 2022, 9:57am UTC](https://community.postman.com/t/need-more-help-on-snapshot-testing-in-postman/33791/2 "2022-03-24T09:57:04Z")

</div>

Hi @rnfasoliz

Have you added the snapshot response as an “example” of your mock server like this?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/0/903ad20c8a7fe581040cc73bd506531797190ef7.png)

Once you have this example you can add your tests in the “tests” tab to check the response data, for example;

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/d/d39cfaac92147424b0827ca5b89e36e3eebb610b.png)

Hope this helps…

---

<div class="post-metadata">

**Author:** ![rnfasoliz](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rnfasoliz](https://community.postman.com/u/rnfasoliz)\
**Post date:** [March 24, 2022, 6:42pm UTC](https://community.postman.com/t/need-more-help-on-snapshot-testing-in-postman/33791/3 "2022-03-24T18:42:03Z")

</div>

Thanks for the reply, but my goal is to validate the json schema and not only the status code. It seemed like snapshot testing is the key. I know how to make a snapshot and create a mock server with that snapshot, but not sure on how the test script is written in order to validate the json schema.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [March 24, 2022, 7:04pm UTC](https://community.postman.com/t/need-more-help-on-snapshot-testing-in-postman/33791/4 "2022-03-24T19:04:34Z")

</div>

Here is a schema validation example for a REST API, it should give you the base structure for whats needed in your test tab;

```auto
const schema = {
    "type": "object",
    "properties": {
        "id": {
      "type": "integer"
    },
    "category": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ]
    },
    "name": {
      "type": "string"
    },
    "photoUrls": {
      "type": "array",
      "items": [
        {
          "type": "string"
        }
      ]
    },
    "tags": {
      "type": "array",
      "items": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "integer"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "name"
          ]
        }
      ]
    },
    "status": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "category",
    "name",
    "photoUrls",
    "tags",
    "status"
  ]
};

pm.test("Validating the API schema", () => {
    pm.response.to.have.jsonSchema(schema);
});

```

---

<div class="post-metadata">

**Author:** ![rnfasoliz](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rnfasoliz](https://community.postman.com/u/rnfasoliz)\
**Post date:** [March 24, 2022, 11:32pm UTC](https://community.postman.com/t/need-more-help-on-snapshot-testing-in-postman/33791/5 "2022-03-24T23:32:11Z")

</div>

Awesome thank you for the help!
