GithubHelp home page GithubHelp logo

prism-contract-testing's Introduction

Contract Testing APIs with Prism & OpenAPI

If you got here by accident, this repository illustrates how to use and experimental Prism programmatic API & jest framework to perform contract testing with minimal amount of code.

You can read more about this stuff in an article I wrote but if you don't care and want to figure it out yourself here are some hints.

Using this code

Prerequisites

  • Install Docker
  • Run httpbin server locally docker run -p 80:80 kennethreitz/httpbin
  • Add httpbin alias to /etc/hosts (optional) sudo su -c 'echo "0.0.0.0 httpbin"' >> /etc/hosts

(Part of this code was inspired by the Prism source code, hence the use of httpbin).

Running tests

yarn # or `npm install`
yarn test

prism-contract-testing's People

Contributors

chris-miaskowski avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

prism-contract-testing's Issues

Update script to latest version of Prism

@chris-miaskowski

I'm really interesting in understanding the sample and use it for own contract testing of OpenApi specs.

I see that the "3.2.0-beta.11" version of Prism is used.

Currently the sample give the following error:

TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
    src/contract.test.ts:11:13 - error TS2352: Conversion of type '{ mock: false; checkSecurity: true; validateRequest: true; validateResponse: true; upstream: URL; }' to type 'IHttpConfig' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
      Property 'errors' is missing in type '{ mock: false; checkSecurity: true; validateRequest: true; validateResponse: true; upstream: URL; }' but required in type 'IHttpConfig'

I assume it is related to the prism-http-server

Any tips or pointers would be helpful.

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.