{"id":17933951,"url":"https://github.com/papooch/nestjs-microservices-testbed","last_synced_at":"2026-05-01T09:31:39.314Z","repository":{"id":226500266,"uuid":"768858075","full_name":"Papooch/nestjs-microservices-testbed","owner":"Papooch","description":"A collection of utilities for integration testing of microservices in NestJS.","archived":false,"fork":false,"pushed_at":"2024-03-20T07:56:46.000Z","size":205,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-23T11:08:36.604Z","etag":null,"topics":["integration","microservices","nestjs","testing","utility"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@nestjs-microservices-testbed/core","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/Papooch.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":"2024-03-07T21:34:59.000Z","updated_at":"2025-08-08T22:17:40.000Z","dependencies_parsed_at":"2024-10-28T21:42:39.126Z","dependency_job_id":"2dba4496-2917-4a33-b0b8-9a595c932931","html_url":"https://github.com/Papooch/nestjs-microservices-testbed","commit_stats":null,"previous_names":["papooch/nestjs-microservices-testbed"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Papooch/nestjs-microservices-testbed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Papooch%2Fnestjs-microservices-testbed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Papooch%2Fnestjs-microservices-testbed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Papooch%2Fnestjs-microservices-testbed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Papooch%2Fnestjs-microservices-testbed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Papooch","download_url":"https://codeload.github.com/Papooch/nestjs-microservices-testbed/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Papooch%2Fnestjs-microservices-testbed/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32492113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["integration","microservices","nestjs","testing","utility"],"created_at":"2024-10-28T21:42:29.824Z","updated_at":"2026-05-01T09:31:39.279Z","avatar_url":"https://github.com/Papooch.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Microservices TestBed\n\nDo yo find it hard to implement integration (e2e) tests for your NestJS microservices without having to run the real broker?\n\nThis project aims to provide a similar testing experience to testing a NestJS HTTP server without having to spin it up.\n\nThe library provides a `MicroserviceTestBed` class that acts as a \"broker\" and exposes a custom microservice _Transporter_ which plugs into the NestJS microservice abstraction.\n\nThis way, you can \"emit\" messages to the test bed and your application would handle them as if they were coming from a real broker. This way you can easily test\n\n\u003e ### ⚠️ Warning 🏗 Under construction 🚧\n\u003e\n\u003e This library is still in a very early stage of development and does not yet support all the features of the NestJs microservices abstraction, namely, there is no support for the `@Context` decorator yet nor for any platform-specific features of other transporters.\n\n## Example\n\n\u003c!-- prettier-ignore --\u003e\n```ts\n// ...other imports\nimport { TestBedClient } from '@nestjs-microservices-testbed/core';\nimport waitForExpect from 'wait-for-expect';\n\nclass ExclamationInterceptor implements NestInterceptor {\n    intercept(context: ExecutionContext, next: CallHandler\u003cany\u003e ): Observable\u003cany\u003e {\n        return next.handle()\n            .pipe(map((result) =\u003e result + '!'));\n    }\n}\n\n@Controller()\nclass TestAppConsumer {\n\n    constructor(\n        @Inject('TEST_CLIENT')\n        private readonly client: ClientProxy,\n    ) {}\n\n    @MessagePattern('say-hello')\n    @UseInterceptors(ExclamationInterceptor)\n    async helloWorld(@Payload() data: string) {\n        return `Hello ${data}`;\n    }\n\n    returnResponse() {\n        return firstValueFrom(this.client.send('handle-response', ''));\n    }\n\n    @MessagePattern('handle-response')\n    handleResponse() {\n        return 'Response!';\n    }\n\n    @EventPattern('events')\n    handleEvent(@Payload() data: string) {\n        this.client.emit('emitted-events', data).subscribe();\n    }\n}\n\n\ndescribe('Microservices Testbed', () =\u003e {\n\n    // create instance of the test bed\n    const testBed = new MicroservicesTestBed();\n    let app: INestMicroservice;\n\n    beforeAll(async () =\u003e {\n        const module = await Test.createTestingModule({\n            imports: [\n                ClientsModule.register([{\n                    name: 'TEST_SERVICE',\n                    // register a custom class to be used as the client\n                    customClass: testBed.getClientClass(),\n                }]);\n            ]\n            controllers: [TestAppConsumer],\n        })\n        app = module.createNestMicroservice\u003cMicroserviceOptions\u003e({\n            // retrieve the test bed server instance\n            strategy: testBed.getServerInstance(),\n        });\n        await app.init();\n    });\n\n    afterAll(() =\u003e app.close());\n\n    it('should handle message pattern', async () =\u003e {\n        // send a message using the test bed\n        const result = await testBed.handleMessage({\n            pattern: 'hello-world',\n            data: 'World',\n        });\n        // observe that your application handled the message\n        // and the interceptor was triggered\n        expect(result).toBe('Hello World!');\n    });\n\n    it('should handle client response', async () =\u003e {\n        // invoke a method that sends a message using the client\n        const result = await app.get(TestAppConsumer).returnResponse();\n        // observe that a response was received through the client\n        expect(result).toBe('Response!');\n    });\n\n    it('should handle event pattern', async () =\u003e {\n        // emit an event using the test bed\n        testBed.handleEvent({\n            pattern: 'events',\n            data: 'event-payload',\n        });\n        await waitForExpect(() =\u003e {\n            // verify that your application handled the event\n            // by checking that it emitted another event\n            expect(\n                testBed.getLastMessageForPattern('emitted-events').data\n            ).toEqual(['event-payload']);\n        });\n    });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpapooch%2Fnestjs-microservices-testbed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpapooch%2Fnestjs-microservices-testbed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpapooch%2Fnestjs-microservices-testbed/lists"}