{"id":20129885,"url":"https://github.com/open-rpc/test-coverage","last_synced_at":"2025-04-09T16:12:26.503Z","repository":{"id":35488010,"uuid":"181955560","full_name":"open-rpc/test-coverage","owner":"open-rpc","description":"Test your OpenRPC Document against an API.","archived":false,"fork":false,"pushed_at":"2025-02-06T19:27:21.000Z","size":1347,"stargazers_count":5,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T16:12:07.773Z","etag":null,"topics":["openrpc-document","test-coverage"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-rpc.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":"2019-04-17T19:28:50.000Z","updated_at":"2025-02-05T14:18:55.000Z","dependencies_parsed_at":"2024-04-15T11:23:31.030Z","dependency_job_id":"597cbdfc-23c1-47be-822b-15e8bc89d966","html_url":"https://github.com/open-rpc/test-coverage","commit_stats":{"total_commits":451,"total_committers":4,"mean_commits":112.75,"dds":0.2195121951219512,"last_synced_commit":"01a6a75fc4beaf206af03204e410f2c777484384"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Ftest-coverage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Ftest-coverage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Ftest-coverage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-rpc%2Ftest-coverage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-rpc","download_url":"https://codeload.github.com/open-rpc/test-coverage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065283,"owners_count":21041872,"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":["openrpc-document","test-coverage"],"created_at":"2024-11-13T20:36:30.954Z","updated_at":"2025-04-09T16:12:26.351Z","avatar_url":"https://github.com/open-rpc.png","language":"TypeScript","readme":"# OpenRPC Test Coverage\n\u003ccenter\u003e\n  \u003cspan\u003e\n    \u003cimg alt=\"CircleCI branch\" src=\"https://img.shields.io/circleci/project/github/open-rpc/test-coverage/master.svg\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/open-rpc/test-coverage/branch/master/graph/badge.svg\" /\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/dt/@open-rpc/test-coverage.svg\" /\u003e\n    \u003cimg alt=\"GitHub release\" src=\"https://img.shields.io/github/release/open-rpc/test-coverage.svg\" /\u003e\n    \u003cimg alt=\"GitHub commits since latest release\" src=\"https://img.shields.io/github/commits-since/open-rpc/test-coverage/latest.svg\" /\u003e\n  \u003c/span\u003e\n\u003c/center\u003e\n\nThis tool is meant to help you test your OpenRPC Document against an API.\n\nNeed help or have a question? Join us on [Discord](https://discord.gg/gREUKuF)!\n\n## The Problem\nEven after writing your OpenRPC Document, you want to test that the OpenRPC Document does represent an actual API.\n\n## Solution\n\n- generate fake data for the OpenRPC Documents method parameters schemas\n- use example pairings when available\n- use the servers[] defined in the OpenRPC Document to make the JSON-RPC API call\n- report back the coverage results\n- show errors and the result to help fix inconsistencies\n\n\n## Extending with a `Rule`\nRules are a way to extend the test coverage tool to check for specific things when calling your JSON-RPC API. For example, you may want to check that some fields are always present in the result.  You can write a rule to check for that.\n\nA rule is a class that extends the `Rule` class and implements the `getCalls` function. The `getCalls` function should return an array of calls to make to the JSON-RPC API. The `Rule` class will then make the calls and check the results. It checks the results with the `validateCall` function, it expects that you mutate the `call.valid` property to `true` if the call is valid, and `false` if the call is invalid.\n\nLastly there are lifecycle events that you can hook into to do things like setup and teardown. The `onBegin` function is called before any calls are made, and the `onEnd` function is called after all calls are made. There are also `beforeRequest`, `afterRequest`, and `afterResponse` lifecycle functions that are called before the request is made, after the request is made, and after the response is received respectively. See the [`Rule`](src/rules/rule.ts) interface for more information.\n\n## Custom Reporters\nYou can write custom reporters to output the results of the test coverage tool in a different format. A reporter is a class that extends the `Reporter` class and implements the lifecycle functions. The `Reporter` class will call the lifecycle functions at the appropriate time. The `onBegin` function is called before any calls are made, and the `onEnd` function is called after all calls are made. There are also `onTestBegin` and `onTestEnd` lifecycle functions that are called before and after each test respectively. See the [`Reporter`](src/reporters/reporter.ts) interface for more information.\n\n### Installation:\n\n```\n\nnpm install -g @open-rpc/test-coverage\n\n```\n\n\n### Usage:\n\n\n```\nopen-rpc-test-coverage -s https://raw.githubusercontent.com/open-rpc/examples/master/service-descriptions/simple-math-openrpc.json --transport=http --reporters=console --skip=addition\n```\n\n\n\n#### Screenshot\n\n##### console reporter\n\n![image](https://user-images.githubusercontent.com/364566/56318521-3e103300-6114-11e9-85cd-f35eb7b42a0e.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-rpc%2Ftest-coverage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-rpc%2Ftest-coverage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-rpc%2Ftest-coverage/lists"}