Coder Social home page Coder Social logo

qontract-node's Introduction

Qontract is a contract driven development tool that allows us to turn our contracts into executable specification.

Quick Start

npm install qontract will install the qontract locally to the node project.

Sample npm scripts to run qontract, with *.qontract as the path of qontract files and src/mocks as the path for the stub data directory (Check Documentation for more information on cli commands and arguments.)

"qontract-stub": "qontract stub *.qontract --data src/mocks --host=localhost --port=8000"

"qontract-test": "qontract test *.qontract --host=localhost --port=8000"

Qontract in stub mode (For consumers)

In stub mode, Qontract provides random responses to requests that match the contract. It’s a way of exploring what the contract looks like. This is meant to be used by anyone who wants to take a fake version of the API for a spin. This mode can also stub out real requests and responses, which will be validated against the contract before being accepted.

Qontract tests (For Providers)

In test mode, Qontracts accepts a contract file, and the hostname and port of the service whose API is being tested. It then sends an HTTP request based on the request format described in the contract for every scenario, generating random values where no examples are given. When the service responds, it validates the response based on the format in the contract. This is meant to be used by API providers.

API

Check Documentation for more information on cli commands and arguments.

Test helper library

import { startStubServer, startTestServer, loadDynamicStub } from 'qontract';

Qontract JS library exposes methods which can be used in your JS project to setup the tests, as well as do advanced things like load stubs dynamically.

startStubServer(qontractDir: string, stubDir: string, host: string, port: string)

method to start the stub server.

startTestServer(qontractDir: string, host: string, port: string)

method to start test server.

loadDynamicStub(stubPath: string)

method to load stub dynamically from inside an automated test.

qontract-node's People

Contributors

harikrishnan83 avatar nashjain avatar sahilaug avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.