happner-test-modules is a supplementary library designed to provide utilities and mock components specifically for testing applications built with the `happner` microservices framework. `happner` is a cloud application framework that enables the creation of an interconnected mesh of local and remote components, utilizing `happn-3` for its pub/sub and data layer. This package (currently at version `1.0.2`) offers helper functions to simplify the setup and teardown of `happner` meshes, the loading of test components, and the simulation of component interactions and event flows. These functionalities are crucial for ensuring the reliability of `happner`-based systems. Given that `happner`'s last significant updates (v1.34.1 and `happner-2`) were several years ago, `happner-test-modules` is likely in maintenance mode, receiving updates primarily for compatibility or critical bug fixes rather than active feature development. Its key differentiator is its tailored integration with the `happner` ecosystem, providing specific test paradigms for mesh components and event APIs.
npm install happner-test-modulesVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create and interact with a basic `happner` mesh using `happner-test-modules` (implicitly through `happner.create`), define a simple component, call a method on it, and emit/receive an event.
Consult the `happner` project's release notes and migration guides (e.g., from `happner-1` to `happner-2`) for specific changes. Update `happner-test-modules` to the latest compatible version.
Ensure each test creates a fresh `happner` mesh instance and cleans it up (e.g., `mesh.stop()`) after completion. Avoid global state or ensure any shared resources are reset before each test run. Consider using a test runner's `beforeEach` and `afterEach` hooks.
Always ensure `mesh.stop()` is called in an `afterEach` or `finally` block for every mesh created in a test, even if the test fails. This guarantees clean resource release.
Ensure that `await Happner.create(config)` has successfully completed before attempting any interactions with the mesh. Handle potential errors during mesh creation.
Verify the `Happner.create(config)` call and its promise resolution. Debug the `mesh` variable to confirm it holds a valid `happner` instance after creation.
Check your `tsconfig.json` (for TypeScript) or Node.js `package.json`'s `type` field and `module` resolution settings. Ensure your test runner (e.g., Jest, Mocha) is configured to handle ESM, or transpile your code to CJS if the environment strictly requires it. For Node.js, ensure `.mjs` or `type: "module"` is used for ESM files, and `.cjs` or `type: "commonjs"` for CJS.