{"id":15697530,"url":"https://github.com/kt3k/stubbatti","last_synced_at":"2026-03-17T14:15:37.744Z","repository":{"id":17473037,"uuid":"20247257","full_name":"kt3k/stubbatti","owner":"kt3k","description":"A command line stub http server with the special DSL.","archived":false,"fork":false,"pushed_at":"2017-06-10T11:11:48.000Z","size":939,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-09T00:57:20.855Z","etag":null,"topics":["http","stub"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kt3k.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}},"created_at":"2014-05-28T06:24:33.000Z","updated_at":"2017-02-27T14:01:21.000Z","dependencies_parsed_at":"2022-09-01T23:30:41.145Z","dependency_job_id":null,"html_url":"https://github.com/kt3k/stubbatti","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kt3k%2Fstubbatti","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kt3k%2Fstubbatti/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kt3k%2Fstubbatti/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kt3k%2Fstubbatti/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kt3k","download_url":"https://codeload.github.com/kt3k/stubbatti/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253171250,"owners_count":21865290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["http","stub"],"created_at":"2024-10-03T19:20:29.127Z","updated_at":"2026-03-17T14:15:32.697Z","avatar_url":"https://github.com/kt3k.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stubbatti v1.2.0\n\n[![Build Status](https://img.shields.io/travis/kt3k/stubbatti.svg?style=flat)](https://travis-ci.org/kt3k/stubbatti)\n[![Coverage Status](https://img.shields.io/coveralls/kt3k/stubbatti.svg?style=flat)](https://coveralls.io/r/kt3k/stubbatti?branch=master)\n[![Npm Version](https://img.shields.io/npm/v/stubbatti.svg?style=flat)](https://www.npmjs.org/package/stubbatti)\n[![MIT License](http://img.shields.io/badge/license-mit-blue.svg?style=flat)](https://github.com/kt3k/stubbatti/blob/master/LICENSE)\n\n[![Dependency Status](https://david-dm.org/kt3k/stubbatti.svg?style=flat)](https://david-dm.org/kt3k/stubbatti)\n\n\u003e A command line stub http server with the special DSL.\n\n**Note:** `stubbatti` is pronunced like **/stəˈbati/**.\n\n# Install\n\n- Install `node.js` ( \u003e= 0.9 ).\n\n- Using `npm`, install `stubbatti` command globally:\n\n```bash\nnpm install -g stubbatti\n```\n\n# Usage\n\nStubbatti is configurable with the file named `.stubbatti.js` or `stubbatti.js`.\n\nAnd in it you can write like following:\n\n```js\nget('/hello', 'Hello, world!');\n```\n\nAnd if you run the command `stubbatti` then stubbatti server will start listening on port 28987 (by default) and will serve the string `Hello, world!` when the path `/hello` requested.\n\n# Reference\n\n## `.stubbatti.js` reference\n\n**Basic Response**\n\nYou can set a response body for the path:\n\n```js\nget('/hello', 'Hello, world!');\n```\n\nWith the above, `/hello` responses `Hello, world!` with http status `200`.\n\n**Response delay**\n\nYou can delay response with `delay` option:\n\n```js\nget('/slow', 'slow response', {delay: 3000});\n```\n\nWith the above, `/slow` responses after the delay of 3000 miliseconds.\n\nThis is useful for testing timeout features of client libraries.\n\n**Content-Type**\n\nYou can specify the content-type of the reponse with `contentType` option:\n\n```js\nget('/json', '{\"a\":1}', {contentType: 'application/json'});\n```\n\nWith the above, `/json` responses `{\"a\":1}` with `Content-Type: application/json`.\n\n**Status Code**\n\nYou can specify the status code of the response with `status` option:\n\n```js\nget('/402', 'payment required', {status: 402});\n```\n\nWith the above, `/402` responses `payment required` with http status code `402`.\n\n**Custom Headers**\n\nYou can specify custom headers with `headers` option:\n\n```js\nget('/custom', '{\"a\":1}', {headers: {\n    'X-Custom': 'abc',\n    'X-Header': 'def'\n}});\n```\n\nWith the above settings, `/custom` responses with the HTTP headers like:\n\n```\nX-Custom: abc\nX-Header: def\n```\n\n**Other Methods**\n\nAvailable methods are `get`, `post`, `head`, `options`, `put`, `delete`.\n\nFollowings are valid notations in `.stubbatti.js`.\n\n```js\nget('/foo', 'GET response');\npost('/foo', 'POST response');\nhead('/foo', ''); // HEAD response cannot have a response body.\noptions('/foo', 'OPTIONS response');\nput('/foo', 'PUT response');\nglobal.delete('/foo', 'DELETE response');\ntrace('/foo', 'TRACE response');\n```\n\n**Setting port**\n\nYou can set the stub server's port number with `port` method:\n\n```\nport(80);\n```\n\nThe default port number of stubbatti is 28987.\n\n**Syntax and semantics**\n\nThe syntax and semantics of `.stubbatti.js` is basically same as `node.js` except some addition of global methods above.\n\n## Command Line Options\n\nWith `--config` option, you can specify a custom stubbatti file.\n\n```bash\nstubbatti --config my_stub_settings.js\n```\n\nWith `--kill` option, you can kill the server. With this option, you can set your test script like following:\n\n```bash\nstubbatti \u0026 # launches a stub server\n\n# run unit test using the stub http server\n...\n\nstubbatti --kill # kills the stub server\n```\n\n## Special Paths\n\nA `HEAD` request to the path `/__kill` has the special meaning, which is used for killing the server process. So you cannot write `head('__kill', ...);` in `.stubbatti.js`.\n\n# LICENSE\n\nMIT\n\n# Note\n\nThis command is a thin wrapper of `express` and focusing on stubbing an http server on test environments. This cli should be useful when you write the unit test of an http client or a web api client.\n\n# [API documentation](http://kt3k.github.io/stubbatti/doc/v1.2.0/)\n\n# Similar tools\n\n- [Betamax](https://github.com/robfletcher/betamax) for JVM languages\n- [VCR](https://github.com/vcr/vcr) for Ruby\n- [WireMock](https://github.com/tomakehurst/wiremock) for JVM languages\n- [Stubby](https://github.com/azagniotov/stubby4j) for JVM languages and has CLI\n  - Stubby is very similar to stubbatti, but the main target is JVM language with gradle build configuration.\n- [wiremock-php](https://github.com/rowanhill/wiremock-php) for PHP\n- [objc-mocktail](https://github.com/square/objc-mocktail) for Objective-C\n\nThe difference of stubbatti from the above tools is that it's just a CLI stub server and can be used with any language through hooks in a shell script.\nAnd it needs only one setting file `.stubbatti.js` with the simple language.\n\n# Release History\n- 2014-06-10   v1.2.0   Added `--help` option.\n- 2014-06-05   v1.1.0   Initial release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkt3k%2Fstubbatti","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkt3k%2Fstubbatti","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkt3k%2Fstubbatti/lists"}