Skip to content
Beth Skurrie edited this page Jan 19, 2015 · 5 revisions

Pact Verification with Javascript (Node?)

Features

  • Verify a pact at a given URL (filesystem or remote via HTTP)
  • Define "set-up" for a provider state for a given consumer
  • Define "tear-down" for a provider state for a given consumer
  • Define "set-up" for all provider states for a given consumer
  • Define "tear-down" for all provider states for a given consumer

Usage

  • Add the following npm packages to the package.json

  • pact-verify (packaged Ruby executable)

  • pact-provider-state-server ("server" or "service"???)

  • Create a provider state server (this will be responsible for setting up the test data on the server under test so that it responds the way that the consumer expects it to)

  • Create a spec/pact-helper.js file

  • TODO: Example here

  • Create a task to start up the provider state server before the tests

  • TODO: Example here

  • Run:

    $ node_modules/pact-verify/bin/pact-verify --pact-url consumer-provider.json --provider-port 8080 --provider-states-port 8181

Other command line options:

    $ pact-verify --help

  --pact-url=PACT_URL                    The URL (local file or http) to the pact to verify.
  --provider-port=PROVIDER_PORT          The port that the provider will run on 
                                           (assuming it is running on http://localhost)
  --provider-base-url=PROVIDER_BASE_URL  eg. https://my-provider:8080,
                                           if not running on http://localhost
  --provider-states-port=
      PROVIDER_STATES_PORT               The port that the provider states server will run on
                                           (assuming it is running on http://localhost)
  --provider-states-base-url=
      PROVIDER_STATES_BASE_URL           eg. https://my-provider-states-server:8181
  --set-up-path=SET_UP_PATH              default: set-up
  --tear-down-path=TEAR_DOWN_PATH        default: tear-down

Tech notes

  • Set up and tear down calls - JSON or form params? Need to include consumer name and provider state name.
  • Set up and tear down calls need to be done even when there is no provider state, so that the global state for that consumer can be set up/torn won.
Clone this wiki locally