Skip to content

Commit

Permalink
Fix API tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-uk committed Nov 8, 2021
1 parent d82d264 commit e21b6bd
Showing 1 changed file with 178 additions and 199 deletions.
377 changes: 178 additions & 199 deletions src/tests/postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,200 +1,179 @@
{
"info": {
"_postman_id": "8c90c22b-3e1f-45c9-aaf5-058b37f34474",
"name": "Node.js Demoapp",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Check Home Page",
"event": [
{
"listen": "test",
"script": {
"id": "e1f514e2-fc14-4fcd-a140-50b3fc9f5a56",
"exec": [
"pm.test(\"Home Page: Successful GET request\", function () {",
" pm.response.to.be.ok;",
"});",
"",
"pm.test(\"Home Page: Response valid & HTML body\", function () {",
" pm.response.to.be.withBody;",
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');",
"});",
"",
"pm.test(\"Home Page: Check content\", function () {",
" pm.expect(pm.response.text()).to.include('Ben Coleman');",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{apphost}}/",
"protocol": "http",
"host": [
"{{apphost}}"
],
"path": [
""
]
}
},
"response": []
},
{
"name": "Check Info Page",
"event": [
{
"listen": "test",
"script": {
"id": "e1f514e2-fc14-4fcd-a140-50b3fc9f5a56",
"exec": [
"pm.test(\"Info Page: Successful GET request\", function () {",
" pm.response.to.be.ok;",
"});",
"",
"pm.test(\"Info Page: Response valid & HTML body\", function () {",
" pm.response.to.be.withBody;",
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');",
"});",
"",
"pm.test(\"Info Page: Check content\", function () {",
" pm.expect(pm.response.text()).to.include('Intel');",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{apphost}}/info",
"protocol": "http",
"host": [
"{{apphost}}"
],
"path": [
"info"
]
}
},
"response": []
},
{
"name": "Check Weather API",
"event": [
{
"listen": "test",
"script": {
"id": "e1f514e2-fc14-4fcd-a140-50b3fc9f5a56",
"exec": [
"pm.test(\"Weather API: Successful GET request\", function () {",
" pm.response.to.be.ok;",
"});",
"",
"pm.test(\"Weather API: Response valid & JSON body\", function () {",
" pm.response.to.be.withBody;",
" pm.response.to.be.json;",
"});",
"",
"pm.test(\"Weather API: Check API response\", function () {",
" var weatherData = pm.response.json();",
" pm.expect(weatherData.temp).to.be.an('number')",
" pm.expect(weatherData.summary).to.exist;",
" pm.expect(weatherData.forecastLong).to.be.an('string')",
" pm.expect(weatherData.forecastShort).to.be.an('string')",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{apphost}}/api/weather/51.40329/0.05619",
"protocol": "http",
"host": [
"{{apphost}}"
],
"path": [
"api",
"weather",
"51.40329",
"0.05619"
]
}
},
"response": []
},
{
"name": "Check Error Page",
"event": [
{
"listen": "test",
"script": {
"id": "e1f514e2-fc14-4fcd-a140-50b3fc9f5a56",
"exec": [
"pm.test(\"Error Page: Returns 500\", function () {",
" pm.response.to.be.error;",
"});",
"",
"pm.test(\"Error Page: Response valid & HTML body\", function () {",
" pm.response.to.be.withBody;",
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');",
"});",
"",
"pm.test(\"Error Page: Check exception\", function () {",
" pm.expect(pm.response.text()).to.include('ReferenceError');",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{apphost}}/tools/error",
"protocol": "http",
"host": [
"{{apphost}}"
],
"path": [
"tools/error"
]
}
},
"response": []
}
]
}
"info": {
"_postman_id": "8c90c22b-3e1f-45c9-aaf5-058b37f34474",
"name": "Node.js Demoapp",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Check Home Page",
"event": [
{
"listen": "test",
"script": {
"id": "e1f514e2-fc14-4fcd-a140-50b3fc9f5a56",
"exec": [
"pm.test(\"Home Page: Successful GET request\", function () {",
" pm.response.to.be.ok;",
"});",
"",
"pm.test(\"Home Page: Response valid & HTML body\", function () {",
" pm.response.to.be.withBody;",
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');",
"});",
"",
"pm.test(\"Home Page: Check content\", function () {",
" pm.expect(pm.response.text()).to.include('Ben Coleman');",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{apphost}}/",
"protocol": "http",
"host": ["{{apphost}}"],
"path": [""]
}
},
"response": []
},
{
"name": "Check Info Page",
"event": [
{
"listen": "test",
"script": {
"id": "e1f514e2-fc14-4fcd-a140-50b3fc9f5a56",
"exec": [
"pm.test(\"Info Page: Successful GET request\", function () {",
" pm.response.to.be.ok;",
"});",
"",
"pm.test(\"Info Page: Response valid & HTML body\", function () {",
" pm.response.to.be.withBody;",
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');",
"});",
"",
"pm.test(\"Info Page: Check content\", function () {",
" pm.expect(pm.response.text()).to.include('Intel');",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{apphost}}/info",
"protocol": "http",
"host": ["{{apphost}}"],
"path": ["info"]
}
},
"response": []
},
{
"name": "Check Weather API",
"event": [
{
"listen": "test",
"script": {
"id": "e1f514e2-fc14-4fcd-a140-50b3fc9f5a56",
"exec": [
"pm.test(\"Weather API: Successful GET request\", function () {",
" pm.response.to.be.ok;",
"});",
"",
"pm.test(\"Weather API: Response valid & JSON body\", function () {",
" pm.response.to.be.withBody;",
" pm.response.to.be.json;",
"});",
"",
"pm.test(\"Weather API: Check API response\", function () {",
" var weatherData = pm.response.json();",
" pm.expect(weatherData.main.temp).to.be.an('number')",
" pm.expect(weatherData.weather[0]).to.exist;",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{apphost}}/api/weather/51.40329/0.05619",
"protocol": "http",
"host": ["{{apphost}}"],
"path": ["api", "weather", "51.40329", "0.05619"]
}
},
"response": []
},
{
"name": "Check Error Page",
"event": [
{
"listen": "test",
"script": {
"id": "e1f514e2-fc14-4fcd-a140-50b3fc9f5a56",
"exec": [
"pm.test(\"Error Page: Returns 500\", function () {",
" pm.response.to.be.error;",
"});",
"",
"pm.test(\"Error Page: Response valid & HTML body\", function () {",
" pm.response.to.be.withBody;",
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');",
"});",
"",
"pm.test(\"Error Page: Check exception\", function () {",
" pm.expect(pm.response.text()).to.include('ReferenceError');",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://{{apphost}}/tools/error",
"protocol": "http",
"host": ["{{apphost}}"],
"path": ["tools/error"]
}
},
"response": []
}
]
}

0 comments on commit e21b6bd

Please sign in to comment.