Setup

Setting up mockit

Running mockit is a fairly straight forward process:

Create fixtures

By default, mockit will scan files ending in .fixture.js under<rootDir>/mockitfor fixtures. You can configure this in mockit.json (See Advance for more details).

project
└───mockit
    └───fixtures
        │   fixture.js
fixture.js
module.exports = {
    url: '/api/sensu',
    data: [
        {
            type: 'Raw',
            power: 2000
        },
        {
            type: 'Stale',
            power: 1
        }
    ]
};

By default, mockit will assume this is a GET request with status of 200 and content-type of application/json. Of course, you can configure this (see Fixture for more details).

Done!

Now, all you need to do is start the server. On your terminal, run npx mockit start. Your mock server will be hosted on http://localhost:3000 while the client will be served on http://localhost:3000/mockit.

Found an issue? Please let us know!.

Last updated