{"id":14971,"library":"test-machinepack-mocha","title":"Mocha Test Driver for Node-Machine Machinepacks","description":"test-machinepack-mocha is a specialized test driver designed to integrate Mocha with the `node-machine` ecosystem's machinepacks. It enables developers to run tests written in the machinepack's custom JSON format using the familiar Mocha test runner. The package is currently stable at version 3.0.0, but its upstream `node-machine` ecosystem and `test-machinepack-mocha` itself appear to be abandoned, with no significant updates or active development for several years. This means there is no active release cadence. Its key differentiator is its deep integration with `node-machine`'s specific testing methodology, making it suitable only for projects built within that framework. It's primarily used as a command-line interface (CLI) tool rather than being imported programmatically.","status":"abandoned","version":"3.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/mikermcneil/test-machinepack-mocha","tags":["javascript","test-machine","mocha","mocha-driver","test-machinepack","node-machine","machine","test-runner","test-driver"],"install":[{"cmd":"npm install test-machinepack-mocha","lang":"bash","label":"npm"},{"cmd":"yarn add test-machinepack-mocha","lang":"bash","label":"yarn"},{"cmd":"pnpm add test-machinepack-mocha","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the underlying test runner and assertion framework.","package":"mocha","optional":false},{"reason":"The generic test runner it extends and integrates with.","package":"test-machinepack","optional":false}],"imports":[],"quickstart":{"code":"# First, install the driver globally (or locally for npx usage):\nnpm install -g test-machinepack-mocha\n\n# Now, let's create a dummy machinepack and its test files.\n# Create a directory for your machinepack:\nmkdir my-simple-machinepack\ncd my-simple-machinepack\n\n# Create a dummy 'machine' file (e.g., index.js):\necho \"module.exports = { friendlyName: 'Add Numbers', description: 'Adds two numbers.', inputs: { a: { type: 'number', required: true }, b: { type: 'number', required: true } }, exits: { success: { outputExample: 3 } }, fn: function (inputs, exits) { return exits.success(inputs.a + inputs.b); } };\" > index.js\n\n# Create a 'tests' directory and a test JSON file:\nmkdir tests\necho '{\n  \"friendlyName\": \"Basic Addition\",\n  \"machine\": \"./index.js\",\n  \"inputs\": {\n    \"a\": 1,\n    \"b\": 2\n  },\n  \"expect\": 3\n}' > tests/add-basic.json\n\n# Now, run the tests using the driver:\ntestmachinepack-mocha","lang":"javascript","description":"Demonstrates global installation and usage of the `test-machinepack-mocha` CLI to run a basic test against a sample machinepack."},"warnings":[{"fix":"Consider migrating away from the `node-machine` ecosystem or maintaining a legacy Node.js environment if this package is critical. Manual patching or forks might be necessary for newer environments.","message":"The `test-machinepack-mocha` package and the broader `node-machine` ecosystem appear to be abandoned. Users may encounter compatibility issues with newer Node.js versions (e.g., Node.js 16+ or 18+), as the package has not received updates for over six years.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Refer to the `node-machine` documentation (e.g., `machinepack-npm`'s test examples) to understand the required JSON structure for writing tests. Do not attempt to write standard Mocha JS tests directly.","message":"Tests for machinepacks are defined in a custom JSON format, not standard Mocha JavaScript test files. This requires developers to learn and adhere to the specific JSON schema for test definitions, which differs significantly from traditional Mocha test suites.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `testmachinepack-mocha` directly from the terminal or integrate it into build scripts via `npm run` or shell commands. Avoid trying to `import` or `require` it in your application code.","message":"The package is primarily a command-line interface (CLI) tool. There is no common or officially supported programmatic API for direct JavaScript `import` or `require` by end-user applications. Attempts to import it programmatically may lead to unexpected behavior or errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If encountering issues, try installing an older, compatible version of Mocha (e.g., `npm install mocha@^7`). Pinning `mocha` in `package.json` to an older version might be required.","message":"Compatibility with recent major versions of Mocha itself (e.g., Mocha v8+) is uncertain due to the package's abandoned status. Underlying `mocha` API changes might break `test-machinepack-mocha`'s execution.","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install the package globally using `npm install -g test-machinepack-mocha` or run it locally using `npx testmachinepack-mocha` within a project where it's a `devDependency`.","cause":"The package was not installed globally or is not in the system's PATH, or `npx` was not used for a local install.","error":"command not found: testmachinepack-mocha"},{"fix":"Ensure your test JSON file (e.g., `tests/my-test.json`) includes a `\"machine\": \"./path/to/your/machine.js\"` property that correctly references the target machine.","cause":"The test JSON file is malformed or missing the `machine` property, which points to the machine file being tested.","error":"Error: Missing required input `machine`"},{"fix":"Review the machine's `fn` implementation for runtime errors and verify that the `expect` value in your test JSON matches the expected output of the machine for the given inputs.","cause":"A machine's `fn` logic threw an uncaught error, or an assertion (e.g., `expect`) in the test JSON failed.","error":"Error: Test exited non-zero with code 1"}],"ecosystem":"npm"}