feat(testing): add Moleculer testing helpers#1356
Closed
Treasure520520 wants to merge 1 commit into
Closed
Conversation
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. |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the testing helpers proposed in moleculerjs/rfcs#3 and the $100 IssueHunt bounty:
Testing.createBroker()for quiet test brokers with test defaultsTesting.EventCatcherto record emitted/broadcast events and wait for matching eventsTesting.MockingCallsto mock dependentbroker.callcalls and inspect call historymockServicesTestingfrom CommonJS, ESM, and TypeScript declarationsBounty reference: https://oss.issuehunt.io/r/moleculerjs/rfcs/issues/3
Related RFC: moleculerjs/rfcs#3
Verification
npx jest test/unit/testing.spec.js --runInBandnpx jest test/unit/testing.spec.js test/unit/service-broker.spec.js test/unit/middleware.spec.js --runInBand --coverage=falsenpx eslint index.js index.mjs src/testing/*.js test/unit/testing.spec.jsnpx prettier --check index.js index.mjs index.d.ts src/testing/*.js src/testing/*.d.ts test/unit/testing.spec.jsnpm run tsdNote:
npx tsc --noEmit --pretty falsecurrently fails on existing Node 22 typings forcrypto.createCipher/createDecipherinsrc/middlewares/transmit/encryption.js; this PR does not touch that code path.