# mocks-server-lite

> Mocking server supporting multiple route variants and mocks

Latest version **0.16.0** (published 2026-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install mocks-server-lite
pnpm add mocks-server-lite
yarn add mocks-server-lite
bun add mocks-server-lite
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.16.0 |
| Published | 2026-03-19 |
| First published | 2024-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 42.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | burt202 |
| Keywords | mocks, server, lite, mock, routes, route variants, web sockets, api, rest, express, testing, development, middleware |

## Links

- npm: https://www.npmjs.com/package/mocks-server-lite
- Repository: https://github.com/burt202/mocks-server-lite
- Homepage: https://github.com/burt202/mocks-server-lite#readme
- Issues: https://github.com/burt202/mocks-server-lite/issues
- npm.io page: https://npm.io/package/mocks-server-lite

## Dependencies (9)

- [ws](https://npm.io/package/ws.md) ^8.19.0
- [zod](https://npm.io/package/zod.md) ^4.3.6
- [cors](https://npm.io/package/cors.md) ^2.8.6
- [chalk](https://npm.io/package/chalk.md) ^5.6.2
- [express](https://npm.io/package/express.md) ^5.2.1
- [date-fns](https://npm.io/package/date-fns.md) ^4.1.0
- [@types/ws](https://npm.io/package/@types/ws.md) ^8.18.1
- [body-parser](https://npm.io/package/body-parser.md) ^2.2.2
- [@inquirer/prompts](https://npm.io/package/@inquirer/prompts.md) ^8.3.2

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.16.0 (latest) — 2026-03-19
- 0.15.0 — 2025-11-27
- 0.14.0 — 2025-11-19
- 0.13.0 — 2025-07-27
- 0.12.1 — 2025-04-28
- 0.12.0 — 2025-03-17
- 0.11.0 — 2025-03-03
- 0.10.0 — 2024-11-07
- 0.9.0 — 2024-10-11
- 0.8.1 — 2024-10-01
- 0.8.0 — 2024-10-01
- 0.7.0 — 2024-09-14
- 0.6.0 — 2024-07-12
- 0.5.0 — 2024-07-11
- 0.4.0 — 2024-07-10
- … 11 more at https://npm.io/package/mocks-server-lite/versions

## README

# Mocks Server Lite

Credit: This is heavily inspired by [mocks-server](https://github.com/mocks-server/main) and takes some of the main concepts from it. It is massively simplified though, currently with only the core functionality as well as being TypeScript first. I created this because the `mocks-server` project doesnt currently seem to be very active and doesnt come with types and a few other features I think is key, which are listed below.

### Introduction

Node.js mock server that can run live, interactive mocks in place of real APIs. It allows you to define many different responses for a same route, so you can change the whole mocked API behavior by simply changing the response of one or many routes while the server is running. This really helps with local FrontEnd development when the BackEnd isnt ready/available and also really good for automated test runs where you want to change how the backing server behaves whilst it is still running.

[Installation/Getting Started](https://github.com/burt202/mocks-server-lite/blob/main/docs/learn.md)

### Main Features

- define multiple static or dynamic mock responses ([variants](https://github.com/burt202/mocks-server-lite/blob/main/docs/learn.md#routes--variants)) for api endpoints ([routes](https://github.com/burt202/mocks-server-lite/blob/main/docs/learn.md#routes--variants))
- group together route mock responses in [collections](https://github.com/burt202/mocks-server-lite/blob/main/docs/learn.md#collections)
- [change route responses](https://github.com/burt202/mocks-server-lite/blob/main/docs/learn.md#change-collection) without having to restart the mocks server
- support route middleware
- add response delays with route override
- call logs so you can return something different on subsequent calls
- [web sockets](https://github.com/burt202/mocks-server-lite/blob/main/docs/learn.md#web-sockets) support
- [static paths](https://github.com/burt202/mocks-server-lite/blob/main/docs/learn.md#static-paths) support

[Learn more...](https://github.com/burt202/mocks-server-lite/blob/main/docs/learn.md)

### FAQ

- What's the advantage of this over https://mswjs.io/?

No advantages per se but different in the fact youre actually calling a mocked server served at a URL rather than the request being intercepted at any level in code. Also different in that I don't see this as a mocking tool to use with `jest` or `vitest`, more to use with local development (if a BackEnd isnt ready/available) or supporting an E2E test run (using tools like `cypress` or `playwright`) where you dont want it hit a real BackEnd.

### Example Repo

[https://github.com/burt202/mocks-server-lite-example](https://github.com/burt202/mocks-server-lite-example)

- all mocking code is in `mocks/`, with the mock server being created in `mocks/server.ts`
- also see how the playwright test run can change the behaviour of the mocks server by caling `setMockCollection` which in turn calls `POST /__set-collection` with a new collection name

---
_Source: https://npm.io/package/mocks-server-lite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
