惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
Jina AI
Jina AI
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
小众软件
小众软件
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
月光博客
月光博客
L
LangChain Blog
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
C
Check Point Blog
U
Unit 42
人人都是产品经理
人人都是产品经理

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Mock any API response in Postman (and let AI build the co...
Anton Kirilchuk · 2026-06-22 · via DEV Community

The hardest part of frontend testing isn't writing the test. It's getting the backend to return the exact response you need: a 500, an empty list, a malformed payload, right when you want it. On a live server that's painful, and sometimes impossible.

Here's the workflow I use instead. I make the app receive any response I want, without touching the backend at all. Postman mock servers do the heavy lifting, and an AI fills them with data.

The idea: a fake backend that looks real

Your frontend doesn't know where the JSON comes from. It calls a URL and trusts whatever comes back. So you point it at a mock server: a fake address that returns responses you defined in advance. Same endpoints, same shapes, zero real backend.

Why not just DevTools or a proxy?

For a quick one-off, browser tools are fine:

  • Chrome DevTools, Local Overrides rewrite a response right in the browser.
  • Charles / Requestly / mitmproxy intercept and swap responses on the fly.

But the override dies when you close the tab, it lives only on your machine, and you can't hand it to a teammate or a CI pipeline. For anything beyond a single check, you want a real, persistent stand.

Step 1: build the collection

In Postman you already (or soon will) have a collection: the same endpoints your real API exposes, with method, URL, body and headers.

Step 2: add example responses

For each request, hit the three dots and pick Add example. An example is a saved response: a status code plus a body. You write it by hand.

Hang several examples on the same endpoint to cover every case:

  • 200 success
  • 404 not found
  • [] empty list
  • 500 server error

Step 3: spin up the mock server

Three dots on the collection, then Mock collection. Postman gives you an address:

https://xxxx.mock.pstmn.io

Step 4: point the frontend at it

Swap the base URL in your app config:

- const API = "https://api.production.com"
+ const API = "https://xxxx.mock.pstmn.io"

That's it. Your frontend now talks to the mock and never notices the difference.

One endpoint, every scenario

Here's where it gets good. You hung 200, 404 and 500 on the same endpoint. Which one does the mock return? It decides by a request header:

x-mock-response-name: order not found

Send that header from your automated test, and a single endpoint runs through every scenario without touching the server or the data:

await fetch(`${API}/orders/42`, {
  headers: { "x-mock-response-name": "server error" }
})
// the mock returns your 500 example

Responses don't have to be static

Postman supports dynamic variables right inside the example body:

{
  "id": "{{$randomInt}}",
  "name": "{{$randomFullName}}",
  "email": "{{$randomEmail}}"
}

Every call comes back with different data instead of one hardcoded blob, so you catch the bugs that only surface on unexpected input.

The part that saves the most time

Writing dozens of example responses by hand is the boring tax on all of this. So I don't.

I hand the whole collection to Claude through the Postman MCP, and it generates the example responses for every endpoint (success, edge cases, malformed payloads) and wires up the mock. I'm not asking it to write code. I'm asking it to assemble a working test stand while I drink my coffee.

That's the shift: AI stopped being "write me this function" and became "build me the tool".


How do you handle this on your team: Postman mocks, a standalone mock service, or still waiting on the backend?