
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
@jordanwalsh23/postman-local-mock-server
Advanced tools
Provides the ability to run Postman collections as a local mock server.
This project brings Postman's collection mocking capability locally enabling you to create mock servers quickly and run tests against these.
npm install -g @jordanwalsh23/postman-local-mock-server
postman-local -c path/to/collection.json -p 8080
x-mock-response-name and x-mock-response-code headers to specify the response you want returned by either name or status code.x-mock-match-request-headers header to match only the responses that contain a specific header.x-mock-match-request-body header to match responses on POST/PATCH/PUT requests.--collection, -c : Path to your collection file
--port, -p : Port you would like to use to host the server 0-65535
--key : Path to Private Key file for TLS protected servers
--cert : Path to Certificate file for TLS protected servers
--debug, -d : Print debug statements to console when running.
--cacheTTL : The time to keep responses in cache - see apicache for options.
npm install @jordanwalsh23/postman-local-mock-serverconst PostmanLocalMockServer = require('@jordanwalsh23/postman-local-mock-server');
let options = {
port = 3555
}
//Create the collection object.
options.collection = JSON.parse(fs.readFileSync('./test/test-collection.json', 'utf8'));
//Create a new server
let server = new PostmanLocalMockServer(options);
//Start the server
server.start();
//Run some requests against your server
axios.get(`http://localhost:3555`).then(res => {
//do something with the mocked response.
});
//Stop the server
server.stop();
This project includes a local cache that can be enabled via the CLI with the --cacheTTL flag or as an object when starting your server e.g.
//Start the server
server.start({
cache: true,
cacheOptions: {
defaultDuration: "500ms"
}
})
The defaultDuration and cacheTTL parameters must either specify a number of milliseconds, or use plain text english. Some valid examples:
defaultDuration: "500ms"
defaultDuration: "1 minute"
defaultDuration: "5 minutes"
defaultDuration: "1 hour"
defaultDuration: "1 day"
Restarting the server will automatically clear the in-memory cache, however if you want to clear the cache while the server is still running you can use the following endpoint:
DELETE http://localhost:<PORT>/cache
204 No Content
Unfortunately this will clash if there is an endpoint in your supplied collection with the path /cache. In that instance you can fork a copy of the source code and change this path manually.
This emulates the endpoints of a collection and the associated example responses. It does not invoke the pre-request or test scripts within a request.
As such, any requests that are reliant on variables (either collection/environment or global) will not work in this library.
If your collection has the same path (e.g. /api/products) available multiple times, the first response defined will be the one returned by default - regardless of whether this is a successful or error response code.
There are several ways to overcome this:
x-mock-response-name header on your requests to name the mock response you want returned.x-mock-response-code header on your requests to specify the response code (e.g. 200, 404) you want returned.If you still cannot get the server to return your specific response, create an issue on this repo with the collection supplied and we'll try to replicate.
x-mock-response-code is used and multiple items are found the algorithm will just return the first item instead of prioritising the 2xx response.Contributions are welcome on this repo. Submit issues or PRs and these will be reviewed for merging.
See the LICENSE file.
FAQs
Provides the ability to run Postman collections as a local mock server.
The npm package @jordanwalsh23/postman-local-mock-server receives a total of 13 weekly downloads. As such, @jordanwalsh23/postman-local-mock-server popularity was classified as not popular.
We found that @jordanwalsh23/postman-local-mock-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.