0
0
Postmantesting~10 mins

Condition 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 check if the response status is 200.

Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status([1]);
});
Drag options to blanks, or click blank then click option'
A500
B404
C200
D201
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong status code like 404 or 500.
Forgetting to put the status code as a number.
2fill in blank
medium

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

Postman
pm.test("Body contains success", function () {
    pm.expect(pm.response.text()).to.include([1]);
});
Drag options to blanks, or click blank then click option'
A"warning"
B"fail"
C"error"
D"success"
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the string.
Checking for the wrong word.
3fill in blank
hard

Fix the error in the code to check if the response header 'Content-Type' is 'application/json'.

Postman
pm.test("Content-Type is JSON", function () {
    pm.expect(pm.response.headers.get([1])).to.eql('application/json');
});
Drag options to blanks, or click blank then click option'
A'Content-Type'
B"Content-Type"
C"content-type"
D'content-type'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong case like 'content-type'.
Not using quotes around the header name.
4fill in blank
hard

Fill both blanks to check if the response time is less than 500 milliseconds.

Postman
pm.test("Response time is fast", function () {
    pm.expect(pm.response.responseTime) [1] [2];
});
Drag options to blanks, or click blank then click option'
A<
B>
C500
D1000
Attempts:
3 left
💡 Hint
Common Mistakes
Using greater than symbol instead of less than.
Using wrong number like 1000.
5fill in blank
hard

Fill all three blanks to create a test that checks if the JSON response has a property 'status' equal to 'success'.

Postman
pm.test("Status is success", function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData.[1]).to.eql([2]);
});
Drag options to blanks, or click blank then click option'
Astatus
B"success"
C'success'
Dresult
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property name like 'result'.
Not using quotes around 'success'.