{"id":31945021,"url":"https://github.com/pubnub/tomato","last_synced_at":"2025-10-14T10:49:09.577Z","repository":{"id":61364962,"uuid":"540509378","full_name":"pubnub/tomato","owner":"pubnub","description":"CLI Mock Server for contract testing","archived":false,"fork":false,"pushed_at":"2024-05-29T08:11:32.000Z","size":460,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-05-29T13:25:56.480Z","etag":null,"topics":["cli","contract-testing","mock-server"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pubnub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-09-23T15:41:07.000Z","updated_at":"2024-05-29T08:11:36.000Z","dependencies_parsed_at":"2023-11-09T10:46:03.033Z","dependency_job_id":"cb69d8a2-1b1a-4d88-bd1f-a33b2b441423","html_url":"https://github.com/pubnub/tomato","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pubnub/tomato","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubnub%2Ftomato","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubnub%2Ftomato/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubnub%2Ftomato/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubnub%2Ftomato/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pubnub","download_url":"https://codeload.github.com/pubnub/tomato/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pubnub%2Ftomato/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018785,"owners_count":26086453,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","contract-testing","mock-server"],"created_at":"2025-10-14T10:48:59.977Z","updated_at":"2025-10-14T10:49:09.571Z","avatar_url":"https://github.com/pubnub.png","language":"TypeScript","readme":"# `@pubnub/tomato` ![npm](https://img.shields.io/npm/v/@pubnub/tomato?style=flat-square)\n\u003e CLI mock server tool for contract testing\n\n## Installation\n\n    npm install @pubnub/tomato\n\n## Usage\n\n    npx tomato\n\n## Configuration\n Tomato will look for a `toma.toml` configuration file in the current working directory.\n \n|Option|Default|Type|Description|\n|-|-|-|-|\n|`port`|`8090`|`number`|Port to start the server at|\n|`contracts`|`./contracts/**/*.ts`|`Glob \\| Glob[]`|Location of the contract files|\n|`openapi`|`./openapi/**/*.yaml`|`Glob \\| Glob[]`|Location of the OpenAPI specs|\n|`env`|_none_|`Record\u003cstring, string\u003e`|Additional environment variables exposed as `process.env`|\n\n\n## Contract files\nContract is a TypeScript file that:\n  - exports its name: \n      \n        export const name = \"MyContractName\"\n\n  - exports a default _consumer_ function:\n\n        export default async function() {}\n\n  - optionally exports a _provider_ function:\n\n        export async function provider() {}\n\n### Contract context\nContracts are run inside an isolated Node.js environment and have access to some additional helpers.\n\n#### `timetoken.now()`\nGenerates a string timetoken with nanosecond resolution.\n\n#### `json(path: string)`\nRead and parse a JSON file.\n\n#### `expect({ description: string, validations?: Array\u003c(request: Request) =\u003e void\u003e}, number?): Promise\u003cRequest\u003e`\nAsynchronous function that waits for the next request (waits for 30000 milliseconds by default, which can be changed with the last argument) and validates it against an array of `assert` functions before returning an instance of `Request`.\n\n#### `expectAll({ description: string, match: (request: Request) =\u003e bool, validations?: Array\u003c(request: Request) =\u003e void\u003e}[], number?): Promise\u003cRequest[]\u003e`\nAsynchronous function that waits for a list of next requests (waits for 30000 milliseconds by default, which can be changed with the last argument) and validates it against an array of `assert` functions before returning an array of `Request` instances.\n\nThis function is useful when a few endpoints can be called simultaneously, and it is unknown which will be accepted first by the mock server.  `match` function will be used to match the validation configuration to the proper request. The returned list of `Request` instances will be ordered in the same order as the passed parameters.\n\n#### `Request.respond({ status: number, headers?: Record\u003cstring, string\u003e, body?: any }): Promise\u003cvoid\u003e`\nAsynchronous function that responds to a request.\n\n#### `assert`\n`assert` groups assertion functions.\n\n##### Examples:\n\n    // expected last segment of path to equal \"hello\"\n    assert.request.path.lastSegment.equals('\"hello\"')\n\n    // expected path to match /^\\/hello/i\n    assert.request.path.matches('^/hello', 'i')\n    \n    // expected path to start with '/v2/request/hello'\n    assert.request.path.startsWith('/v2/request/hello') \n\n    // expected method to be one of [\"GET\", \"POST\"]\n    assert.request.method.isOneOf(['GET', 'POST'])\n\n    // expected method to equal \"POST\"\n    assert.request.method.equals('POST')\n\n    // expected query[\"lmao\"] to equal \"123\"\n    assert.request.query.lmao.equals('123')\n\n    // expected query[\"tt\"] to be greater than 10\n    assert.request.query.tt.asNumber.gt(10) ","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpubnub%2Ftomato","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpubnub%2Ftomato","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpubnub%2Ftomato/lists"}