0
0
Postmantesting~20 mins

Generating dynamic data in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dynamic Data Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Postman pre-request script?
Consider this Postman pre-request script that generates a random integer between 1 and 10 and sets it as an environment variable. What will be the value type of the environment variable randomNumber after running this script?
Postman
const randomNumber = Math.floor(Math.random() * 10) + 1;
pm.environment.set('randomNumber', randomNumber);
AA number type, e.g., 7
BA string representing the number, e.g., "7"
CAn object containing the number, e.g., {value: 7}
DUndefined, because environment variables cannot be set dynamically
Attempts:
2 left
💡 Hint
Remember that Postman environment variables store values as strings.
assertion
intermediate
2:00remaining
Which assertion correctly verifies a dynamic timestamp in Postman test script?
You have a response JSON with a field timestamp that contains the current time in ISO format. Which Postman test assertion correctly checks that timestamp is a valid ISO date string?
Postman
const jsonData = pm.response.json();
Apm.expect(Date.parse(jsonData.timestamp)).to.be.NaN;
Bpm.expect(jsonData.timestamp).to.be.a('date');
Cpm.expect(new Date(jsonData.timestamp).toString()).to.not.equal('Invalid Date');
Dpm.expect(jsonData.timestamp).to.equal(new Date().toISOString());
Attempts:
2 left
💡 Hint
Check how JavaScript Date parsing works and how to detect invalid dates.
🔧 Debug
advanced
2:00remaining
Why does this Postman script fail to generate a unique email each time?
This pre-request script is intended to generate a unique email by appending a timestamp, but it always sets the same email value. What is the cause?
Postman
const timestamp = pm.environment.get('timestamp');
if (!timestamp) {
  pm.environment.set('timestamp', Date.now());
}
const email = `user_${timestamp}@example.com`;
pm.environment.set('email', email);
AThe timestamp is set only once and never updated, so email stays the same.
BDate.now() returns a constant value in Postman scripts.
CEnvironment variables cannot be used in pre-request scripts.
DThe email variable is not set correctly due to string interpolation error.
Attempts:
2 left
💡 Hint
Check when and how the timestamp environment variable is updated.
framework
advanced
2:00remaining
Which Postman feature best supports generating dynamic test data for multiple iterations?
You want to run a collection multiple times with different dynamic data generated on each iteration. Which Postman feature allows you to do this most effectively?
AUsing the Collection Runner with a data file containing static values
BManually changing environment variables before each run
CUsing Postman monitors to schedule runs without data variation
DUsing pre-request scripts with dynamic data generation and Collection Runner iterations
Attempts:
2 left
💡 Hint
Think about how to generate fresh data automatically for each iteration.
🧠 Conceptual
expert
2:00remaining
What is the main advantage of using dynamic data generation in API testing with Postman?
Why is generating dynamic data during API tests important instead of using only static test data?
AIt helps simulate real-world scenarios by avoiding data duplication and conflicts.
BIt reduces the need for assertions in test scripts.
CIt guarantees that tests will always pass regardless of API changes.
DIt eliminates the need for environment variables.
Attempts:
2 left
💡 Hint
Think about how static data can cause problems in repeated tests.