Skip to content

feat(testing): add Moleculer testing helpers#1356

Closed
Treasure520520 wants to merge 1 commit into
moleculerjs:masterfrom
Treasure520520:bounty/rfc-3-testing-helpers
Closed

feat(testing): add Moleculer testing helpers#1356
Treasure520520 wants to merge 1 commit into
moleculerjs:masterfrom
Treasure520520:bounty/rfc-3-testing-helpers

Conversation

@Treasure520520
Copy link
Copy Markdown

Summary

Implements the testing helpers proposed in moleculerjs/rfcs#3 and the $100 IssueHunt bounty:

  • adds Testing.createBroker() for quiet test brokers with test defaults
  • adds Testing.EventCatcher to record emitted/broadcast events and wait for matching events
  • adds Testing.MockingCalls to mock dependent broker.call calls and inspect call history
  • supports registering local mock services through mockServices
  • exports Testing from CommonJS, ESM, and TypeScript declarations

Bounty reference: https://oss.issuehunt.io/r/moleculerjs/rfcs/issues/3
Related RFC: moleculerjs/rfcs#3

Verification

  • npx jest test/unit/testing.spec.js --runInBand
  • npx jest test/unit/testing.spec.js test/unit/service-broker.spec.js test/unit/middleware.spec.js --runInBand --coverage=false
  • npx eslint index.js index.mjs src/testing/*.js test/unit/testing.spec.js
  • npx prettier --check index.js index.mjs index.d.ts src/testing/*.js src/testing/*.d.ts test/unit/testing.spec.js
  • npm run tsd

Note: npx tsc --noEmit --pretty false currently fails on existing Node 22 typings for crypto.createCipher/createDecipher in src/middlewares/transmit/encryption.js; this PR does not touch that code path.

@Treasure520520
Copy link
Copy Markdown
Author

Codacy is green and there are no open review comments. This PR is ready for maintainer review from my side.

Bounty reference: IssueHunt issue #1304.

@icebob-ai
Copy link
Copy Markdown
Contributor

Closing this PR. There are multiple duplicate PRs implementing the same RFC #3, and we'll be handling the testing helpers implementation internally as part of the v0.15 release. Thank you for your interest in contributing to Moleculer.

@icebob-ai icebob-ai closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants