mock-ff

2.0.2 • Public • Published

Mock For Frontend

This package aim to help the frontend development by providing a wrapper over mockserver package.

Expectations

You just gonna need to create a new folder to store your expectations, for more info in how to create expectations you can find here and here

Sample

// ./expectations/login.json
[
  {
    "httpRequest": {
      "method": "POST",
      "path": "/login"
    },
    "httpResponse": {
      "body": "token"
    }
  }
]

Or

// ./expectations/js-sample.js
module.exports = (mockClient) => {
  mockClient
    .mockAnyResponse({
      httpRequest: {
        method: "GET",
        path: "/jssample",
      },
      httpResponse: {
        body: "EXPECTATION LOAD FROM JS FILE",
      },
    })
    .then(
      function () {
        console.log("expectation created");
      },
      function (error) {
        console.log(error);
      }
    );
};

PS: The mock server load JSON expectation before JS expectations

How to use

Execute the following command

$ npm i -g mock-ff
$ mock-ff help
$ mock-ff start ./expectations/ -p 7777
$ [optional] mock-ff stop -p 7777

PS: Make sure you have the right permissions to read/write in the folder you are executing the command or mock-ff will fail.

This command will start your mockserver on port 7777

Useful requests

Healthcheck

curl --request POST --url http://localhost:7777/mockserver/healthcheck

Recorded Requests and Responses

curl --request PUT --url 'http://localhost:7777/mockserver/retrieve?type=REQUEST_RESPONSES'

Dependencies

  • JDK 11+

Readme

Keywords

none

Package Sidebar

Install

npm i mock-ff

Weekly Downloads

10

Version

2.0.2

License

ISC

Unpacked Size

18.9 kB

Total Files

17

Last publish

Collaborators

  • trovarius