Skip to content

Raw test runner for machinepacks (also includes a generic driver)

Notifications You must be signed in to change notification settings

node-machine/test-machinepack

Repository files navigation

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-name.json, or machine-name.json5 if you want comment support
{
  //name of the machine as per filename
  "machine": "machine-name",
  //within expectations you define the tests of your machine
  //based on the inputs and exits you have defined
  "expectations": [
    {
      //todo truthy means the test will be skipped
      "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

© 2015-2017 Mike McNeil

About

Raw test runner for machinepacks (also includes a generic driver)

Resources

Stars

Watchers

Forks

Packages

No packages published