Mocks

Creating mocks

A mock is a special route convention that allow to create routes that will never be promoted to production.

> api
  > users
    + mock.ts

Mocks are ideal to quickly fake, tests and agree on the data expected from an API. With mocks, you can define the constraints and boundaries of an API without working on its actual implementation.

/api/users/mock.ts
export default () => {
  return [
    {
      name: "jane",
    },
    {
      name: "bob",
    },
  ];
};

In Sensai, a mock follow the same conventions than a route.