0
0
Postmantesting~10 mins

Alert configuration 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 set the alert condition to trigger when the response status code is 404.

Postman
pm.test('Status code is 404', function () { pm.response.to.have.status([1]); });
Drag options to blanks, or click blank then click option'
A200
B404
C500
D301
Attempts:
3 left
💡 Hint
Common Mistakes
Using a status code other than 404 will not trigger the alert correctly.
Forgetting to put the status code as a number inside the function.
2fill in blank
medium

Complete the code to check if the response time is less than 200 milliseconds.

Postman
pm.test('Response time is fast', function () { pm.expect(pm.response.responseTime).to.be.[1](200); });
Drag options to blanks, or click blank then click option'
Aabove
Bbelow
CgreaterThan
DlessThan
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'above' or 'greaterThan' will check the opposite condition.
Using 'below' is not a valid Chai assertion method.
3fill in blank
hard

Fix the error in the code to correctly check if the JSON response has a property 'success' set to true.

Postman
pm.test('Response has success true', function () { pm.expect(pm.response.json().[1]).to.eql(true); });
Drag options to blanks, or click blank then click option'
Aget('success')
BhasOwnProperty('success')
Csuccess
Dincludes('success')
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like hasOwnProperty returns a boolean, not the property value.
Using get or includes are not valid for plain JSON objects.
4fill in blank
hard

Fill both blanks to create an alert that checks if the response body contains the string 'error' and the status code is 500.

Postman
pm.test('Error response check', function () { pm.expect(pm.response.text().[1]('error')).to.be.[2]; pm.response.to.have.status(500); });
Drag options to blanks, or click blank then click option'
Aincludes
Btrue
Cfalse
DindexOf
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'indexOf' alone without comparing to -1 will not return a boolean.
Asserting 'false' will fail the test if 'error' is present.
5fill in blank
hard

Fill all three blanks to create a test that verifies the response JSON has a property 'data' which is an array with length greater than 0.

Postman
pm.test('Data array is not empty', function () { const jsonData = pm.response.json(); pm.expect(jsonData.[1]).to.be.an('[2]').and.to.have.length.[3](0); });
Drag options to blanks, or click blank then click option'
Adata
Barray
Cabove
Dobject
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'object' instead of 'array' will fail the type check.
Using 'length.above' with a negative or zero value will fail the test.