Bird
Raised Fist0
Postmantesting~20 mins

Alert configuration in Postman - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Alert Configuration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Alert Conditions in Postman Monitors

Which of the following alert conditions in Postman Monitors will trigger an alert only when the response time exceeds 2000 milliseconds?

AresponseTime < 2000
BresponseTime >= 2000
CresponseTime > 2000
DresponseTime == 2000
Attempts:
2 left
💡 Hint

Think about the condition that strictly checks if response time is more than 2000 ms.

❓ Predict Output
intermediate
2:00remaining
Output of Alert Script with Status Code Check

What will be the output of the following Postman test script if the response status code is 404?

Postman
if (pm.response.code !== 200) {
    pm.alerts.trigger('Status code is not OK');
} else {
    pm.alerts.clear();
}

pm.test('Check alert triggered', () => {
    pm.expect(pm.alerts.hasAlerts()).to.be.true;
});
ATest fails because alert is not triggered
BTest passes because alert is triggered
CSyntaxError due to pm.alerts.trigger usage
DRuntime error: pm.alerts is undefined
Attempts:
2 left
💡 Hint

Check what happens when status code is not 200.

❓ assertion
advanced
2:00remaining
Correct Assertion for Alert Message Content

Which assertion correctly verifies that the alert message contains the word 'timeout' in Postman test scripts?

Postman
const alertMessages = pm.alerts.getAll().map(alert => alert.message);
Apm.expect(alertMessages.contains('timeout')).to.be.true;
Bpm.expect(alertMessages.includes('timeout')).to.be.true;
Cpm.expect(alertMessages.find('timeout')).to.exist;
Dpm.expect(alertMessages.some(msg => msg.includes('timeout'))).to.be.true;
Attempts:
2 left
💡 Hint

Remember that alertMessages is an array of strings.

🔧 Debug
advanced
2:00remaining
Debugging Alert Not Triggering in Postman

A Postman monitor alert is not triggering even though the response time exceeds the threshold. Which is the most likely cause?

AThe alert condition uses <code>responseTime &lt; 2000</code> instead of <code>&gt;</code>
BThe response time is measured in seconds, but condition expects milliseconds
CThe alert script uses <code>pm.alerts.trigger()</code> incorrectly with no message
DThe monitor is disabled in Postman settings
Attempts:
2 left
💡 Hint

Check the alert condition logic carefully.

❓ framework
expert
3:00remaining
Best Practice for Configuring Multiple Alerts in Postman Monitors

When configuring multiple alerts for different failure conditions in a Postman monitor, which approach ensures clear and maintainable alert management?

AUse separate <code>pm.alerts.trigger()</code> calls with distinct messages for each condition inside one test script
BCombine all conditions into one <code>if</code> statement and trigger a single alert with a generic message
CUse <code>pm.alerts.clear()</code> at the start and trigger alerts only for the first failing condition
DTrigger alerts only after the monitor run completes using external webhook integration
Attempts:
2 left
💡 Hint

Think about clarity and traceability of alerts.

Practice

(1/5)
1. What is the main purpose of configuring alerts in Postman during API testing?
easy
A. To notify testers when a test condition fails
B. To automatically fix API errors
C. To generate API documentation
D. To speed up API response times

Solution

  1. Step 1: Understand alert purpose in testing

    Alerts are used to inform testers about issues or failures during tests.
  2. Step 2: Identify correct alert function

    Alerts notify when test conditions fail, helping catch problems early.
  3. Final Answer:

    To notify testers when a test condition fails -> Option A
  4. Quick Check:

    Alerts = Notifications on failure [OK]
Hint: Alerts notify failures, not fix or document [OK]
Common Mistakes:
  • Thinking alerts fix errors automatically
  • Confusing alerts with documentation tools
  • Assuming alerts improve response speed
2. Which of the following is the correct way to set an alert message in a Postman test script when a response status is not 200?
easy
A. pm.test('Status is 200', () => pm.response.to.have.status(200));
B. pm.alert('Status is not 200');
C. pm.test('Status is 200', () => { if(pm.response.code !== 200) pm.alert('Status is not 200'); });
D. pm.response.alert('Status check');

Solution

  1. Step 1: Identify correct test syntax

    Postman uses pm.test() to define tests and pm.response.to.have.status() to check status.
  2. Step 2: Check alert usage

    pm.alert() is not a valid Postman function; alerts come from test failures.
  3. Final Answer:

    pm.test('Status is 200', () => pm.response.to.have.status(200)); -> Option A
  4. Quick Check:

    Use pm.test with assertions [OK]
Hint: Use pm.test with assertions, no pm.alert function [OK]
Common Mistakes:
  • Using pm.alert which does not exist
  • Trying to call alert on response object
  • Not using pm.test for assertions
3. Given this Postman test script:
pm.test('Response time is less than 500ms', () => {
  pm.expect(pm.response.responseTime).to.be.below(500);
});

What will happen if the response time is 600ms?
medium
A. The test will pass and no alert is shown
B. The test will pass but an alert is triggered
C. The script will cause a syntax error
D. The test will fail and an alert is triggered

Solution

  1. Step 1: Understand the test condition

    The test expects response time below 500ms.
  2. Step 2: Analyze response time 600ms

    600ms is above 500ms, so the condition fails and test fails.
  3. Final Answer:

    The test will fail and an alert is triggered -> Option D
  4. Quick Check:

    Fail if responseTime >= 500ms [OK]
Hint: Fail test if condition false triggers alert [OK]
Common Mistakes:
  • Assuming test passes despite failure
  • Thinking alerts show on pass
  • Confusing syntax error with test failure
4. You wrote this Postman test script:
pm.test('Check status', () => {
  pm.expect(pm.response.status).to.equal(200);
});

But the test always fails even when the API returns 200. What is the error?
medium
A. pm.expect is used incorrectly
B. pm.test syntax is wrong
C. pm.response.status should be pm.response.code
D. The API never returns 200

Solution

  1. Step 1: Check property for status code

    Postman uses pm.response.code for status code, not pm.response.status.
  2. Step 2: Correct the property usage

    Replace pm.response.status with pm.response.code to fix the test.
  3. Final Answer:

    pm.response.status should be pm.response.code -> Option C
  4. Quick Check:

    Use pm.response.code for status [OK]
Hint: Use pm.response.code, not pm.response.status [OK]
Common Mistakes:
  • Using pm.response.status instead of pm.response.code
  • Misusing pm.expect syntax
  • Assuming API never returns 200 without checking
5. You want to configure an alert in Postman that triggers only when the response JSON has a field error set to true. Which test script correctly sets this alert?
hard
A. pm.test('Error field check', () => { pm.expect(pm.response.json().error).to.be.false; });
B. pm.test('Error field check', () => { const json = pm.response.json(); pm.expect(json.error).to.eql(true); });
C. pm.test('Error field check', () => { const json = pm.response.json(); if(json.error === true) pm.alert('Error found'); });
D. pm.test('Error field check', () => { pm.response.to.have.jsonBody('error', true); });

Solution

  1. Step 1: Understand how to check JSON field in Postman

    Use pm.response.json() to parse JSON, then assert field value.
  2. Step 2: Identify correct assertion syntax

    pm.expect(...).to.eql(true) correctly asserts that error is true, triggering failure if not.
  3. Step 3: Evaluate options

    pm.test('Error field check', () => { pm.expect(pm.response.json().error).to.be.false; }); expects error to be false, which is opposite of requirement; pm.test('Error field check', () => { const json = pm.response.json(); if(json.error === true) pm.alert('Error found'); }); uses invalid pm.alert; pm.test('Error field check', () => { pm.response.to.have.jsonBody('error', true); }); uses invalid method.
  4. Final Answer:

    pm.test('Error field check', () => { const json = pm.response.json(); pm.expect(json.error).to.eql(true); }); -> Option B
  5. Quick Check:

    Use pm.expect(...).to.eql(true) to assert error true [OK]
Hint: Use pm.expect with .to.eql(true) for boolean alerts [OK]
Common Mistakes:
  • Using pm.alert which does not exist
  • Incorrect assertion methods
  • Not parsing JSON before checking
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard