Registry / testing / test-machinepack-mocha

test-machinepack-mocha

JSON →
library3.0.0jsnpmunverified

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.

npm install test-machinepack-mocha
INSTALL
IMPORT
SIG · TEST-MACHINEPACK-M
T
test-machinepack-mocha
testingjavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Demonstrates global installation and usage of the `test-machinepack-mocha` CLI to run a basic test against a sample machinepack.

# First, install the driver globally (or locally for npx usage): npm install -g test-machinepack-mocha # Now, let's create a dummy machinepack and its test files. # Create a directory for your machinepack: mkdir my-simple-machinepack cd my-simple-machinepack # Create a dummy 'machine' file (e.g., index.js): echo "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 # Create a 'tests' directory and a test JSON file: mkdir tests echo '{ "friendlyName": "Basic Addition", "machine": "./index.js", "inputs": { "a": 1, "b": 2 }, "expect": 3 }' > tests/add-basic.json # Now, run the tests using the driver: testmachinepack-mocha
test-machinepack-mocha --version
Debug
Known issues
breakingThe `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.
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.
affects: >=3.0.0
gotchaTests 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.
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.
affects: >=1.0.0
gotchaThe 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.
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.
affects: >=1.0.0
breakingCompatibility 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.
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.
affects: >=3.0.0
Errors
Common errors & fixes
command not found: testmachinepack-mocha
The package was not installed globally or is not in the system's PATH, or `npx` was not used for a local install.
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`.
Error: Missing required input `machine`
The test JSON file is malformed or missing the `machine` property, which points to the machine file being tested.
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.
Error: Test exited non-zero with code 1
A machine's `fn` logic threw an uncaught error, or an assertion (e.g., `expect`) in the test JSON failed.
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.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
mocharequiredProvides the underlying test runner and assertion framework.
test-machinepackrequiredThe generic test runner it extends and integrates with.
Agent activity
4 hits · last 30 days
node
4
Resources
test-machinepack-mocha — npm install test-machinepack-mocha · libregistry