Skip to content
🎣static type to mock data
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
src
.gitignore
README.md
package.json
yarn.lock

README.md

mock.macro

Welcome! This project is mainly used to demonstrate how to create a babel macro. Of course if you think this project may help you or if you have idea to make it better, let's talk about it!

this is a macro (read about babel-plugin-macros if you are not familiar) to generate mock data using type system.

Example Usage

// @flow
import type { mock } from 'mock.macro';

async function foo(): mock<{ id: number, name: string }> {
  // TODO: implement
  return fetch('api/not/ready');
}

// somewhere else
const response = await foo();
console.log(response); 
/* { id: 4916, name: 'Sausages' } */

Prior Art

Manta Style - Mock server that converts type definitions into mock data

You can’t perform that action at this time.