-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasic_API_Test_spec.js
57 lines (50 loc) · 1.31 KB
/
Basic_API_Test_spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var frisby = require('frisby');
frisby.create('Testing API - Posts')
.get('http://jsonplaceholder.typicode.com/posts/2')
.expectStatus(200)
.expectHeaderContains('content-type', 'application/json')
.expectJSONTypes({
"userId": Number,
"id": Number,
"title": String,
"body": String
}).inspectBody().toss();
frisby.create('Testing API - Existing Users - Test passing')
.get('http://jsonplaceholder.typicode.com/users/1')
.expectStatus(200)
.expectJSONTypes({
"id": Number,
"name": String,
"username": String,
"email": String
})
.expectJSON(
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "[email protected]"
})
.toss();
frisby.create('Testing API - 404 status expected')
.get('http://jsonplaceholder.typicode.com/users/500')
.expectStatus(404)
.toss();
//Example of test failure
frisby.create('Testing API - Existing Users - Test failure')
.get('http://jsonplaceholder.typicode.com/users/1')
.expectStatus(200)
.expectJSONTypes({
"id": Number,
"name": String,
"username": String,
"email": String
})
.expectJSON(
{
"id": 1,
"name": "Leanne Graham11",
"username": "Bret",
"email": "[email protected]"
})
.toss();