explaingit

nuysoft/mock

19,621JavaScriptAudience · developerComplexity · 2/5DormantLicenseSetup · easy

TLDR

JavaScript library that generates realistic fake data and intercepts network requests to let frontend developers build and test without a live backend.

Mindmap

mindmap
  root((repo))
    What it does
      Generates fake data
      Intercepts Ajax requests
      Returns mock responses
    How to use it
      Define data template
      Specify data shape
      Get random values
    Use cases
      Frontend without backend
      Automated testing
      Development workflow
    Tech stack
      JavaScript
      Ajax interception
      npm package

Things people build with this

USE CASE 1

Build a frontend interface while waiting for the backend API to be ready.

USE CASE 2

Write automated tests with predictable fake data without depending on a live server.

USE CASE 3

Generate realistic test data like names, dates, addresses, and numbers for development.

USE CASE 4

Intercept and mock Ajax requests so frontend code runs as if the real API were live.

Tech stack

JavaScriptjQueryKISSY

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

Mock.js is a JavaScript library for generating realistic fake data to use during development and testing. The problem it solves is common in web development: the backend API is not yet ready, but the frontend developer still needs to build and test their interface. Rather than waiting or manually typing in test values, Mock.js lets you define a template describing what shape your data should have, and then automatically produces random but believable values, names, dates, numbers, addresses, and so on, that match that shape. It also intercepts Ajax requests (the way browser-based apps fetch data from a server) and responds with fake data, so the frontend code can run as if the real API were live. This is particularly useful when writing automated tests, where you want predictable inputs and don't want to depend on a live server. The library supports templates written in JavaScript or HTML and works alongside jQuery and KISSY (an older Chinese web framework). Mock.js is installable via npm and available under the MIT license.

Copy-paste prompts

Prompt 1
Show me how to set up Mock.js to generate fake user data with names, emails, and addresses for my frontend tests.
Prompt 2
How do I use Mock.js to intercept Ajax requests and return mock responses so my frontend works without a backend?
Prompt 3
Create a Mock.js template that generates a list of 10 fake products with realistic names, prices, and descriptions.
Prompt 4
How can I use Mock.js in my automated test suite to provide consistent fake data without hitting a real API?
Prompt 5
Show me an example of using Mock.js with jQuery to mock API responses for a login form.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.