Skip to content

Instantly share code, notes, and snippets.

@ShahOdin
Created March 13, 2022 01:43
Show Gist options
  • Save ShahOdin/593dae58883114cb3ccc5c52e76b3cb8 to your computer and use it in GitHub Desktop.
Save ShahOdin/593dae58883114cb3ccc5c52e76b3cb8 to your computer and use it in GitHub Desktop.
{
"info": {
"_postman_id": "3673316a-9a35-4b0d-a148-3566b490798d",
"name": "Hello World",
"description": "A simple collection with one request that has tests to validate response. You can use this collection as a entry-levle example to demonstrate Postman's debugging capabilities.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Hello World",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const jsonData = pm.response.json();",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.be.success;",
"});",
"",
"pm.test(\"Ensure `data` property exists and contains `message`\", function () {",
" pm.response.to.have.jsonSchema({",
" properties: {",
" data: {",
" type: \"object\",",
" properties: {",
" message: {",
" type: \"string\"",
" }",
" }",
" }",
" }",
" });",
"});",
"",
"pm.test(\"Ensure valid message\", function () {",
" pm.expect(jsonData.data.message).to.eql('Hello, World!');",
"})"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"message\": \"Hello, World!\"\n}"
},
"url": {
"raw": "https://postman-echo.com/post",
"protocol": "https",
"host": [
"postman-echo",
"com"
],
"path": [
"post"
]
}
},
"response": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment