{"id":22287592,"url":"https://github.com/botchris/grpc-web-mock","last_synced_at":"2025-10-12T13:46:15.449Z","repository":{"id":59542484,"uuid":"537834095","full_name":"botchris/grpc-web-mock","owner":"botchris","description":"A simple pure typescript grpc-web mocking library","archived":false,"fork":false,"pushed_at":"2025-09-18T13:22:04.000Z","size":260,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-18T15:51:40.946Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/botchris.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-09-17T14:31:19.000Z","updated_at":"2025-09-18T13:22:07.000Z","dependencies_parsed_at":"2025-09-18T15:20:59.941Z","dependency_job_id":"d2b84fb9-0df6-44ca-8fa8-850906352e20","html_url":"https://github.com/botchris/grpc-web-mock","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/botchris/grpc-web-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botchris%2Fgrpc-web-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botchris%2Fgrpc-web-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botchris%2Fgrpc-web-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botchris%2Fgrpc-web-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/botchris","download_url":"https://codeload.github.com/botchris/grpc-web-mock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botchris%2Fgrpc-web-mock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279011456,"owners_count":26084947,"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-12T02:00:06.719Z","response_time":53,"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":[],"created_at":"2024-12-03T17:00:42.974Z","updated_at":"2025-10-12T13:46:15.444Z","avatar_url":"https://github.com/botchris.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GRPC-Web Mock\n\nAllows to mock GRPC-Web responses in pure Typescript. Useful for mocking\nGRPC-Web APIs in E2E tests.\n\n## Motivation\n\nGRPC-Web is a protocol that allows to use GRPC services in the browser. It is\nimplemented in many languages, including Typescript. However, testing GRPC-Web\nservices is not as easy as testing REST APIs (you usually mock a bunch of JSON\nresponses, and you are ready to go).\n\nThis library aims to make E2E tests easier by simulating the part of the\nGRPC-Web server that is responsible for sending responses to a web-client\n(see [wiring format](https://github.com/grpc/grpc-web#wire-format-mode) for\nfurther details). It allows to mock GRPC-Web responses in pure Typescript,\nwithout the need to run a real GRPC server. Simply create a new ProtocolBuffer\nmessage, and pass it to one of the mocking functions to get a valid GRPC-Web\nresponse as it would be sent by a real GRPC server.\n\nHowever, this library does not mock the GRPC-Web client or server interfaces,\nso you still need to simulate HTTP networking. Below you can find an example of\nhow to use this library with [Cypress](https://www.cypress.io/), which provides\na nice API for intercepting HTTP requests and mocking responses.\n\n## Cypress Example\n\n```typescript\nimport * as grpcMock from \"grpc-web-mock\";\nimport { ListOrdersResponse, Order } from \"./gen/protos/orders_pb\";\n\ndescribe(\"Orders Service\", () =\u003e {\n    it(\"should returns a list of orders\", () =\u003e {\n        // Intercept Backend request and inject a mocked grpc-web response.\n        cy.intercept(\n            {\n                method: \"POST\",\n                pathname: \"/shopping.api.v1.OrdersService/ListOrders\",\n            },\n            (req) =\u003e {\n                // 1. Mock a Protobuffer response object as it would be \n                // returned by the real GRPC server.\n                const res = new ListOrdersResponse();\n                const orders = [] as Order[];\n                \n                for (let i = 0; i \u003c 10; i++) {\n                    const order = new Order();\n                    order.setId(i);\n                    order.setPrice(1000);\n                    order.setQuantity(1);\n                    orders.push(order);\n                }\n                \n                res.setOrdersList(orders);\n\n                // 2. Change response for a mocked \"grpc-web-text\" response.\n                req.reply(grpcMock.ToTextResponse(res));\n            }\n        ).as(\"@listOrders\");\n\n        cy.visit(\"/orders/list\");\n        cy.wait(\"@listOrders\")\n        cy.get(\"[data-cy=orders-table]\").find(\"tr\").should(\"have.length\", 10);\n    });\n});\n```\n\n## Development\n\n### Install dependencies\n\n```bash\nyarn install\n```\n\n### Run tests\n\n```bash\nyarn test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotchris%2Fgrpc-web-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbotchris%2Fgrpc-web-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotchris%2Fgrpc-web-mock/lists"}