0
0
Postmantesting~10 mins

Output block in Postman - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to log the response status code in Postman test script.

Postman
pm.test("Status code is 200", function () {
    pm.expect(pm.response.[1]).to.eql(200);
});
Drag options to blanks, or click blank then click option'
Acode
Bstatus
Cbody
Dheaders
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.response.status instead of pm.response.code
Trying to access pm.response.body for status code
2fill in blank
medium

Complete the code to check if the response body contains the string 'success'.

Postman
pm.test("Body contains success", function () {
    pm.expect(pm.response.text().[1]("success")).to.be.true;
});
Drag options to blanks, or click blank then click option'
Asearch
BindexOf
Cincludes
Dmatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using indexOf which returns a number, not a boolean
Using match which returns an array or null
3fill in blank
hard

Fix the error in the code to correctly parse JSON response and check a property.

Postman
pm.test("Check user id", function () {
    let jsonData = pm.response.[1]();
    pm.expect(jsonData.userId).to.eql(1);
});
Drag options to blanks, or click blank then click option'
Ajson
Btext
Cbody
Draw
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.response.text() which returns a string, not an object
Trying to access pm.response.body() which is not a method
4fill in blank
hard

Fill both blanks to check if the response header 'Content-Type' is 'application/json'.

Postman
pm.test("Content-Type is JSON", function () {
    pm.expect(pm.response.[1].get([2])).to.eql('application/json');
});
Drag options to blanks, or click blank then click option'
Aheaders
B"Content-Type"
C"content-type"
Dbody
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.response.body instead of headers
Not quoting the header name string
5fill in blank
hard

Fill all three blanks to create a test that checks if the response time is less than 200ms.

Postman
pm.test("Response time is fast", function () {
    pm.expect(pm.response.[1]).to.be.[2]([3]);
});
Drag options to blanks, or click blank then click option'
AresponseTime
Bbelow
C200
Dabove
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'above' instead of 'below' for less than check
Not using the correct property name for response time