0
0
Postmantesting~10 mins

Timestamp generation in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test checks if the Postman script correctly generates a current timestamp and verifies its format and value.

Test Code - Postman
Postman
pm.test("Timestamp is generated and valid", function () {
    const timestamp = Date.now();
    pm.environment.set("currentTimestamp", timestamp);
    pm.expect(timestamp).to.be.a('number');
    pm.expect(timestamp).to.be.above(0);
});
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsPostman test runner is ready to execute the test script-PASS
2Generates current timestamp using Date.now()Timestamp is a numeric value representing milliseconds since Unix epochCheck that timestamp is a numberPASS
3Stores timestamp in Postman environment variable 'currentTimestamp'Environment variable 'currentTimestamp' holds the timestamp value-PASS
4Asserts timestamp is greater than zeroTimestamp value is positive and validVerify timestamp > 0PASS
5Test endsTest completed successfully with all assertions passing-PASS
Failure Scenario
Failing Condition: Timestamp is not generated or is not a number
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the timestamp?
AThat it is exactly the current date and time as a string
BThat it is a string in ISO format
CThat it is a number and greater than zero
DThat it is stored in a global variable
Key Result
Always verify that generated timestamps are numeric and positive to ensure valid time values before using them in tests or requests.