Run a mock locally and inspect its logs and state
Run a mock locally to develop against it before you deploy it. Start the mock on your machine, send requests to it at localhost, and watch its logs and state as it handles each request. To make a mock always available to your team instead, deploy it as a mock server.
The steps in this section use the Postman desktop app. To run a mock from the command line, including in CI, use the postman mock run command.
Start a mock and send local requests
Start a mock and send it HTTP requests to validate that it behaves as expected. The URL is http://localhost:<port>, where the port is specified in the mock’s settings. If the specified port is already in use, the mock falls back to an available port assigned by the OS. You can manually start and stop the mock to control when it listens for requests.
- Click the
Items tab in the sidebar.
- Click Mocks.
- Select the mock.
- Click Start in the upper right. You can also select
View more actions > Start next to a mock in the sidebar.
- In the upper right, click
Open in a new request to open a new request with the URL auto-filled. You can also click
Copy URL to copy the URL and use it in an HTTP request.
- Send requests to the URL and observe the responses.
Click Stop in the upper right to stop the mock.
You can also start a mock locally from the Postman CLI with the postman mock run command.
Inspect a running mock
View requests, responses, and state information for a running mock.
- Click the
Items tab in the sidebar, click Mocks, then select a mock.
- Use the Session dropdown list to inspect a specific state session. Requests that use the same session identifier share state and display together.
- Use the Logs and State tabs to inspect requests, responses, and state information for the mock.
View logs
View incoming requests, responses, and state operations in the Logs tab.
You can filter logs by path, type, method, status, time range, and header to focus on specific requests and responses. For example, you can filter by a specific endpoint to see all requests made to that endpoint and the corresponding responses.
Select a log entry to view more details about the request and response, including headers and body content.
Logs with the simulator icon indicate requests that ran with a simulation applied.
Click Clear logs to remove all logs for the mock.
View state
If your mock uses pm.state, you can inspect the current state values for the selected session in the State tab.
State entries are displayed as key-value pairs. Expand a state entry to view its contents and inspect how requests have modified state over time.
Click Clear session to remove all state values for the selected session.
View mock history
Each time you start a mock, Postman records the run. Use mock history to review past runs, including who started each one, how long it ran, and the logs and state captured during the run.
Click History to view the mock’s past runs.
The history table lists each run with the following details:
Use the Started by and Source filters to narrow the list.
You can also open a mock’s past runs from the History tab in the sidebar. To learn more, see History.