{"id":16015697,"url":"https://github.com/radekbednarik/mockserver-cli","last_synced_at":"2026-02-21T09:01:41.826Z","repository":{"id":212066706,"uuid":"728195845","full_name":"radekBednarik/mockserver-cli","owner":"radekBednarik","description":"CLI interface for handling expectations (mocks) on the mockserver instance of https://www.mock-server.com","archived":false,"fork":false,"pushed_at":"2025-11-18T05:26:12.000Z","size":263,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-18T07:19:19.977Z","etag":null,"topics":["cli","mocking-utility","mockserver","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/radekBednarik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-06T12:38:34.000Z","updated_at":"2025-11-18T05:25:12.000Z","dependencies_parsed_at":"2024-05-06T09:42:22.596Z","dependency_job_id":"90bf33d0-8d72-48b3-b838-566f1cc90bb8","html_url":"https://github.com/radekBednarik/mockserver-cli","commit_stats":null,"previous_names":["radekbednarik/mockserver-cli"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/radekBednarik/mockserver-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radekBednarik%2Fmockserver-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radekBednarik%2Fmockserver-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radekBednarik%2Fmockserver-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radekBednarik%2Fmockserver-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/radekBednarik","download_url":"https://codeload.github.com/radekBednarik/mockserver-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radekBednarik%2Fmockserver-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29677881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T06:23:40.028Z","status":"ssl_error","status_checked_at":"2026-02-21T06:23:39.222Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","mocking-utility","mockserver","nodejs"],"created_at":"2024-10-08T15:42:05.138Z","updated_at":"2026-02-21T09:01:41.808Z","avatar_url":"https://github.com/radekBednarik.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mockserver-cli\n\nUtility for handling expectations setup, teardown and other action on [MockServer](https://www.mock-server.com/mock_server/creating_expectations.html) instance.\n\n## System Preconditions\n\n- [Node.js](https://nodejs.org/en/) - developed and tested on v20.10.0\n\n## Installation for usage of the library\n\n1. run `npm i -g @bednarik_radek/mockserver-cli`. Global installation is recommended for usage of the library. So it will be accessible from any directory.\n\n2. run `npx expectations -h` to see the list of available commands. Will display something like this:\n\n```bash\nnpx expectations -h\n\n# output\nUsage: expectations [options] [command]\n\nOptions:\n  -V, --version                    output the version number\n  -c, --config \u003cpath\u003e              set config path. defaults to './mockserver.config.json' (default: \"./mockserver.config.json\")\n  --concurrency \u003cnumber\u003e           set number of concurrent requests. defaults to '10' (default: \"10\")\n  -h, --help                       display help for command\n\nCommands:\n  set \u003cpaths...\u003e                   send prepared expectations up to the mockserver instance\n  clear \u003cpaths...\u003e                 clear all expectations from the mockserver instance\n  reset                            resets all expectations and request logs in the running mockserver instance\n  get-active [options] \u003cpaths...\u003e  get all active expectations from the mockserver instance\n  help [command]                   display help for command\n```\n\n## Installation for development\n\n1. clone the [repository](git@github.com:radekBednarik/mockserver-cli.git)\n\n2. run `npm i` to install dependencies\n\n## How to Run\n\n### Global options\n\n#### Set config path\n\n```bash\nnpx expectations -c ./examples/mockserver.config.json set ./examples/expectations/expectation1.json\n```\n\n#### Configuration file format\n\nExample:\n\n```json\n{\n  \"host\": \"localhost\",\n  \"port\": 5999,\n  \"protocol\": \"\u003chttp|https\u003e\"\n}\n```\n\nFile can be placed anywhere. If `-c` or `--config` option is not provided, program will look for `mockserver.config.json` in the current directory.\n\n#### Set concurrency\n\nConcurrency of promises sets, how many promises many promises will be held in the queue at max to resolve. Defaults to `10`.\n\nThis limiting is applied for both `set`, `clear` and `get-active` commands.\n\n- `set` is limited for how many expectations requests to mock-server can be sent at once.\n\n- `clear` is limited for how many `expectations.json` files can be processed at once. If the expectations array in the file contains multiple expectations, they will be processed one by one sequentially.\n\n- `get-active` is limited for how many requests to mock-server regarding active expectations for the given expectation of the `.expectations.json` file can be sent at once.\n\nUses [p-queue](https://github.com/sindresorhus/p-queue) library under the hood.\n\n```bash\nnpx expectations --concurrency=5 set ./examples/expectations/expectation1.json\n```\n\n### Set Expectations\n\nExpectations definitions are stored in `json` files. These files can be placed anywhere.\n\n#### Expectation file format\n\n- file name must end with `.expectations.json`\n\n- file must contain array of expectations objects\n\n- see [Mockserver documentation](https://www.mock-server.com/mock_server/creating_expectations.html) for more details about expectations\n\nExample:\n\n```json\n[\n  {\n    \"httpRequest\": {\n      \"method\": \"GET\",\n      \"path\": \"/api/test/endpoint/v1\"\n    },\n    \"httpResponse\": {\n      \"statusCode\": 200,\n      \"body\": \"Hello World!\"\n    }\n  },\n  {\n    \"httpRequest\": {\n      \"method\": \"GET\",\n      \"path\": \"/api/test/endpoint/v2\"\n    },\n    \"httpResponse\": {\n      \"statusCode\": 200,\n      \"body\": {\n        \"message\": \"Hello World!\",\n        \"flag\": \"test\"\n      }\n    }\n  }\n]\n```\n\n#### Set Expectations from a single file\n\n```bash\nnpx expectations -c=some/filepath/mockserver.config.json --concurrency=50 set ./examples/expectations/expectation1.json\n```\n\n#### Set Expectations from multiple files\n\n```bash\nnpx expectations set ./examples/expectations/expectation1.json ./examples/expectations/expectation2.json\n```\n\n#### Set Expectations from a directory\n\n```bash\nnpx expectations set ./examples/expectations\n```\n\n#### Set Expectations from multiple directories\n\n```bash\nnpx expectations set ./examples/expectations ./examples/expectations2\n```\n\n### Clear Expectations\n\n#### Clear Expectations from a single file\n\n```bash\nnpx expectations clear ./examples/expectations/expectation1.json\n```\n\n#### Clear Expectations from multiple files\n\n```bash\n\nnpx expectations clear ./examples/expectations/expectation1.json ./examples/expectations/expectation2.json\n```\n\n#### Clear Expectations from a directory\n\n```bash\nnpx expectations clear ./examples/expectations\n```\n\n#### Clear Expectations from multiple directories\n\n```bash\nnpx expectations clear ./examples/expectations ./examples/expectations2\n```\n\n### Reset MockServer\n\nResets all expectations and logs in the running mockserver instance.\n\n```bash\nnpx expectations reset\n```\n\n### Get Active Expectations\n\nYou have to provide the path(s) to the directory or file containing the expectations.\n\nYou may provide option `-s` or `--save` to save the active expectations to the `.json` file.\n\nOtherwise, the expectations are only logged to the console with `trace` log level.\n\n```bash\n# retrieves active expectations from the mockserver instance and does NOT save them to the file.\nnpx expectations -c some/path/to/mockserver.config.json get-active ./examples/expectations/expectation1.json\n\n# retrieves active expectations from the mockserver instance and saves them to the file.\nnpx expectations -c some/path/to/mockserver.config.json get-active examples/expectations/expectation1.json -s retrieved-active-expectations.json\n```\n\n## Logging\n\nLogging is done via [pino.js](https://getpino.io/) library. Currently, there is only the possibility to log to the console.\n\n### Log Levels\n\n- see [logger levels in pino docs](https://getpino.io/#/docs/api?id=levels)\n\n### Logger settings\n\nThese are done via `ENV` variables.\n\n- `LOG_LEVEL` - set log level. Defaults to `info` if not provided.\n\n- `LOG_ENABLED` - set log enabled. Defaults to `true` if not provided.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradekbednarik%2Fmockserver-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fradekbednarik%2Fmockserver-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradekbednarik%2Fmockserver-cli/lists"}