doraemon

A module and http API mock tool.

Usage no npm install needed!

<script type="module">
  import doraemon from 'https://cdn.skypack.dev/doraemon';
</script>

README

Doraemon

Build Status

A module API data mock tool.

You can use Doraemon to mock unfinished module api data.

Install

npm install doraemon

Usage

define module

// ./moduleA.js
module.exports = {
    say: function(what) {
    }
};

add module

var D = require("doraemon")({
    mock: true,
    dataPath: "./__MOCKS__/",
    q: true
});

// add module
D.add("moduleA", require("moduleA"));

// require module
D.require("moduleA").say()
.then(function(data) {
    console.log(data); // ouput "hello, world!"
})
.fail(function(e) {
    //
}); 

mock file

./MOCKS/moduleA.say.js

module.exports = exports = "hello, world!";