chanwoo00106 / mockios

A library that helps run-time testing by putting fake data instead of Axios.

Home Page:https://www.npmjs.com/package/mockios

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mockios

A library that helps run-time testing by putting fake data instead of Axios.

Installing

When use npm

$ npm install --save-dev mockios

When use yarn

$ yarn add --dev mockios

How to use

CodeSandBox example

import axios from "axios";
import mockios, { MockDataType } from "mockios";

const mockData: MockDataType = {
  get: {
    // method
    "/hello": [
      // url
      { ok: true, message: "hello world" }, // response body
      { baseURL: "http://localhost:3000" }, // response config
    ],
  },
};

const query =
  process.env.NODE_ENV === "development" ? mockios(mockData) : axios;

query.get("/hello").then(({ data }) => {
  console.log(data); // { ok: true, message: 'hello world' }
});

About

A library that helps run-time testing by putting fake data instead of Axios.

https://www.npmjs.com/package/mockios


Languages

Language:TypeScript 68.0%Language:CSS 14.4%Language:JavaScript 13.4%Language:HTML 4.3%