{"id":17976,"library":"test-machinepack","title":"Machinepack Test Runner","description":"test-machinepack provides a raw command-line test runner specifically designed for `node-machine` 'machinepacks'. Its current stable version is 3.0.1, though the last known development activity dates back to 2017, suggesting it is in maintenance mode rather than active development. While it includes a basic, generic test driver, the documentation explicitly recommends against using it for production testing, instead pointing to more robust, community-maintained drivers like `test-machinepack-mocha`. The primary function of this package is to expose a consistent interface for running tests defined in JSON or JSON5 format within a machinepack's `tests` directory, thereby enabling custom test drivers to integrate seamlessly with the `node-machine` ecosystem.","status":"maintenance","version":"3.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/mikermcneil/test-machinepack","tags":["javascript","test-machine","test-machinepack","node-machine","machine","test-runner","test-driver"],"install":[{"cmd":"npm install test-machinepack","lang":"bash","label":"npm"},{"cmd":"yarn add test-machinepack","lang":"bash","label":"yarn"},{"cmd":"pnpm add test-machinepack","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for generating skeleton test files ('pm scrub') and for the core functionality of running tests against machine definitions.","package":"machinepack","optional":false}],"imports":[{"note":"The primary way to use this package is via its globally installed CLI command. Installation via `npm install -g` is typically required.","wrong":"node testmachinepack","symbol":"testmachinepack CLI","correct":"testmachinepack"},{"note":"Programmatic usage is primarily for building custom test drivers. The package exports a single function as its default (CommonJS) export. ESM named imports will not work.","wrong":"import { runTests } from 'test-machinepack';","symbol":"runTests","correct":"const runTests = require('test-machinepack');"},{"note":"While primarily a CommonJS package from 2017, modern bundlers can often handle importing the default CommonJS export as an ESM default import.","wrong":"import * as testMachinepack from 'test-machinepack';","symbol":"runTests (ESM)","correct":"import runTests from 'test-machinepack';"}],"quickstart":{"code":"npm install -g test-machinepack\nmkdir my-awesome-machinepack\ncd my-awesome-machinepack\n# Assuming you have `machinepack` installed globally to use `pm scrub`\n# npm install -g machinepack\npm scrub\nmkdir tests\ncat > tests/example-machine.json5 <<EOF\n{\n  \"machine\": \"example-machine\",\n  \"expectations\": [\n    {\n      \"using\": {\n        \"input1\": \"hello\"\n      },\n      \"outcome\": \"success\"\n    },\n    {\n      \"using\": {\n        \"input1\": \"\"\n      },\n      \"outcome\": \"error\",\n      \"todo\": true\n    }\n  ]\n}\nEOF\n\n# Run tests using the built-in (basic) driver\ntestmachinepack","lang":"javascript","description":"Demonstrates global installation and basic CLI usage of `test-machinepack` to run tests defined in a JSON5 file within a simulated machinepack structure."},"warnings":[{"fix":"Migrate to a recommended external test driver (e.g., `test-machinepack-mocha`) for comprehensive testing needs. This module should primarily be used for its runner interface for custom drivers.","message":"The built-in test driver included with `test-machinepack` is explicitly labeled as 'pretty basic' and not recommended for serious use. Users are encouraged to utilize external drivers, such as `test-machinepack-mocha`, for more robust and feature-rich testing.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Evaluate the stability and compatibility with your current Node.js environment. For new projects, consider alternatives or be prepared to fork and maintain the package yourself if extensive `node-machine` testing is required.","message":"The package appears to be unmaintained since 2017 based on its GitHub activity and copyright dates. While functional, it may not receive updates for new Node.js versions or security fixes, potentially leading to compatibility issues.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Familiarize yourself with the `node-machine` test specification and the JSON/JSON5 structure. Refer to the examples provided in `machinepack-npm`'s test directory for practical usage patterns.","message":"Test definitions are written in JSON or JSON5 format, which differs significantly from traditional JavaScript/TypeScript test files. This can be a steep learning curve for developers unfamiliar with the `node-machine` convention.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Install the package globally using `npm install -g test-machinepack`.","cause":"The `testmachinepack` command-line utility was not installed globally or is not in your system's PATH.","error":"command not found: testmachinepack"},{"fix":"Carefully review the specified test file for malformed JSON or JSON5 syntax. Tools like `jsonlint` or online JSON validators can help identify issues.","cause":"The JSON or JSON5 test file contains syntax errors, making it unparseable by the runner.","error":"Error: Failed to parse test file: [filepath].json5 (SyntaxError: Unexpected token ...)"},{"fix":"Ensure the `machine` property in your JSON/JSON5 test file exactly matches the identity of an existing machine within your machinepack. Verify the machine's file name and export.","cause":"The `machine` property in your test file refers to a machine identity that does not exist or is not exposed by your machinepack.","error":"Error: Could not find 'machine' with identity 'some-machine' in the current machinepack."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}