test-machinepack
Raw test runner for machinepacks (also includes a generic driver)
Note that this built-in test driver is pretty basic-- I wouldn't recommend using it. There is a better driver for mocha that you might enjoy: https://github.com/mikermcneil/test-machinepack-mocha
The point of this module is mainly to expose a test runner.
Confused? See http://node-machine.org for documentation.
Installation
npm install -g test-machinepack
Usage
You can use the generic driver to run tests. To do that, just cd
into your machinepack and then run:
testmachinepack
Writing tests
Tests will be written in JSON or JSON5 format (with .json5 file ending). For each machine you have define you create a JSON file with the same name within a tests
folder. If you install machinepack and run pm scrub
skeleton files will be created for you.
The general format looks like this:
{
"machine": "machine-name",
"expectations": [
{
"todo": true,
"using": {
"variable1": ""
},
"outcome": ""
},
{
"using": {
"variable1": "value"
},
"outcome": "error"
},
{
"using": {
"variable": "value1",
"variable2": "value2"
},
"outcome": "error"
}
]
}
So what do real tests look like?
Check out this example from machinepack-npm:
https://github.com/mikermcneil/machinepack-npm/blob/master/tests/list-packages.json
Custom drivers
Want to build a driver for the test framework of your choice?
See https://github.com/mikermcneil/test-machinepack-mocha for an example, and check out the files in this repo to see how the driver interface is exposed.
License
MIT