Code Monkey home page Code Monkey logo

specmatic-order-ui-js's Introduction

Specmatic Sample: UI calling BFF

This sample project contains a small static website built using HTML and plain javascript that demonstrates how we can contract driven development and testing of client side/front end by stubbing calls to BFF using specmatic stub option and backend OpenAPI spec.

Here is the BFF contract/open api spec

Definitions

  • BFF: Backend for Front End
  • Domain API: API managing the domain model
  • Specmatic Stub Server: Create a server that can replace a real service using its open api spec

Background

A typical web application might look like this. Specmatic can contract driven development and testing of all the three components below. In this sample project, we look how to do this for the UI which is dependent on BFF.

HTML client talks to client API which talks to backend api

The architecture diagram was created using the amazing free online SVG editor at Vectr.

Tech

  1. HTML, Javascript
  2. Specmatic
  3. Karma, Mocha

Start UI

This will start the static server for front end UI

npm start

Access UI at http://localhost:3000 Note: Unless BFF is running on port 8082, above UI will not present any data. Move to next section for solution!

Start UI with BFF Stub

This will start the static server with BFF stubbed

npm run startWithStub

Access UI again at http://localhost:3000 with random order data presented each time the page is refreshed.

Run Tests

This will start the specmatic stub server for BFF and run the karma tests on headless chrome.

npm test

specmatic-order-ui-js's People

Contributors

dependabot[bot] avatar harikrishnan83 avatar joelrosario avatar nashjain avatar vikram-rao avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.