0
0
Postmantesting~15 mins

Description formatting (Markdown) in Postman - Build an Automation Script

Choose your learning style9 modes available
Verify Markdown formatting in Postman request description
Preconditions (2)
Step 1: Open the request in Postman
Step 2: Click on the 'Description' tab below the request URL field
Step 3: Enter the following Markdown text in the description field:
Step 4: # Heading 1
Step 5: ## Heading 2
Step 6: **Bold Text**
Step 7: *Italic Text*
Step 8: - List item 1
Step 9: - List item 2
Step 10: [Link](https://www.postman.com)
Step 11: Switch to the 'Preview' tab to view the rendered Markdown
Step 12: Verify that the description renders the Markdown correctly
✅ Expected Result: The description preview shows a Heading 1, Heading 2, bold text, italic text, a bulleted list with two items, and a clickable link to https://www.postman.com
Automation Requirements - Postman Test Scripts
Assertions Needed:
Verify description field contains the exact Markdown text
Verify the rendered preview matches expected Markdown formatting (headings, bold, italic, list, link)
Best Practices:
Use Postman scripting API to access request description
Validate raw description text and rendered HTML output if accessible
Keep test scripts simple and maintainable
Automated Solution
Postman
pm.test('Description contains correct Markdown', () => {
    const description = pm.request.description.toString();
    pm.expect(description).to.include('# Heading 1');
    pm.expect(description).to.include('## Heading 2');
    pm.expect(description).to.include('**Bold Text**');
    pm.expect(description).to.include('*Italic Text*');
    pm.expect(description).to.include('- List item 1');
    pm.expect(description).to.include('- List item 2');
    pm.expect(description).to.include('[Link](https://www.postman.com)');
});

// Note: Postman test scripts cannot directly verify rendered preview HTML,
// so manual verification or external tools are needed for full rendering check.

This test script checks that the request description contains the exact Markdown text entered. It uses pm.request.description.toString() to get the raw description text. Then it asserts that all Markdown elements like headings, bold, italic, list items, and link syntax are present as expected.

Since Postman test scripts cannot access the rendered HTML preview of the description, this script focuses on verifying the raw Markdown content. Manual verification of the rendered preview is recommended to ensure correct formatting.

Common Mistakes - 3 Pitfalls
Trying to assert rendered Markdown preview using Postman test scripts
Using incorrect property to access description (e.g., pm.request.description.value)
Not escaping special characters in Markdown when asserting
Bonus Challenge

Add tests to verify description formatting for multiple requests with different Markdown content

Show Hint