Code Monkey home page Code Monkey logo

mockable's Introduction

Mockable

Mock your API with an API.

Get Started

With npm:

npm install mockable-api --save-dev

With yarn:

yarn add mockable-api --dev

Then, simply launch the server:

npm run mockable

Override default options:

DEBUG=false MOCKABLE_PORT=3001 npm run mockable

## Use with Cypress

Configure the url of your mockable server with an environment variable in your cypress.json file:

{
  "env": {
    "mockableUrl": "http://localhost:3001/_mock"
  }
}

Note: default url http://localhost:3001/_mock

startServerMock

Use it before each of your test. It ensures no mock is still pending.

  beforeEach(() => {
    cy.startServerMock()
  })

stopServerMock

Use it after each of your test. It cleans all active mocks. Also, it logs still active mocks before cleaning if you're indebug mode.

  afterEach(() => {
    cy.stopServerMock()
  })

mockRequest

Use it like cy.route command.

  cy.mockRequest({
      method: 'GET',
      url: '/api/user',
      status: 200,
      response: {
        username: 'johndoe'
      }
  })

mockable's People

Contributors

quef avatar

Watchers

James Cloos 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.