Fixture

Properties

*required

key

description

default

description

Information about this fixture. This gets display on the client for you to easily decide on which contract to choose from

"No description added"

url*

API endpoint

statusCode

Response code

200

id

Unique id of the fixture

uuidv4

default

If contracts have the same method and url, then use the one with the default value of true

false

method

HTTP method

GET

data

Data to send

handler(req,res)

Custom response handler

headers

Response headers

{'Content-Type': 'application/json'}

validator: {

url: string;

headers: Headers

}

Endpoint to test against

Example fixture

fixture.js
module.exports = {
  default: true,
  description: "Testing service api",
  method: 'GET',
  url: '/api/test',
  statusCode: 200,
  headers: {
    'Content-Type': 'text/plain'
  },
  data: 'Hello World!',
  handler: (req, res) => {
    // Use handlers to do very fine grained responses
    const data = req.body;
    res.json({ message: 'Overrides data specified above.' );
  },
  validator: {
    url: 'http://realwebserver.com/api',
    headers: {
      'Authorization': '*****',
    }
  }
};

Last updated