Pretender.js
Pretender.js is a free, open-source mock server library for XMLHttpRequest and Fetch in the browser.
What Pretender.js is
Pretender.js is a free, open-source mock server library for XMLHttpRequest and Fetch in the browser. It temporarily replaces the native request objects so developers can define routes and handlers with an Express- or Sinatra-style syntax. The routing DSL includes get, put, post, delete, patch, and head methods. Handlers can return an HTTP status, headers, and body, or return a Promise. Routes may respond synchronously, asynchronously, after a delay, or only when manually resolved. A route can also pass requests through to native XMLHttpRequest. Pretender tracks handlers and handled, unhandled, and pass-through requests, with an option to disable tracking. The README documents npm or Yarn installation, direct browser loading, and module imports. Call shutdown() when finished to restore native XMLHttpRequest. The project uses the MIT license, and its repository provides an Issues page for reports and discussion.
Good
- Open-source MIT license
- Express- and Sinatra-style routing
- Supports XMLHttpRequest and Fetch
- Configurable response timing
- Tracks handled and unhandled requests
Watch out
- Works only in the browser
- Requires shutdown() for restoration
- Repository listed updated January 29, 2024
Who it suits
Pretender.js suits browser developers who need controllable XMLHttpRequest or Fetch responses. It is useful for route mocking with configurable timing and optional pass-through behavior.
Verdict
Pretender.js offers browser-only request interception with flexible handlers, timing, and pass-through controls. Its MIT license permits use and modification without charge.
The facts
Each one read from Pretender.js's own pages, with the date it was checked.
Where it runs
- Browser only
- Pretender temporarily replaces native XMLHttpRequest and Fetch to intercept requests, and the README says it only works in the browser.checked 11 Oct 2026
- Browser-only
- Pretender only works in the browser.checked 4 Oct 2026
What it does
- Cleanup
- The README instructs users to call shutdown() when finished to restore the native XMLHttpRequest object.checked 11 Oct 2026
- Installation
- The README shows installation with yarn add -D pretender or npm install --save-dev pretender.checked 4 Oct 2026
- License
- The package metadata identifies the license as MIT.checked 11 Oct 2026
- Maintenance activity
- The Pretender organization page lists the repository as updated Jan 29, 2024.checked 11 Oct 2026
- Module use
- The README shows Pretender loaded directly in a browser or imported as a module.checked 4 Oct 2026
- Pass-through
- Configured requests can pass through Pretender and be sent as real XMLHttpRequests.checked 11 Oct 2026
- Purpose
- Pretender is a mock server library for XMLHttpRequest and Fetch with an Express/Sinatra-style routing syntax.checked 4 Oct 2026
- Request tracking
- Pretender tracks handled, unhandled, and pass-through requests, and request tracking can be disabled with an option.checked 11 Oct 2026
- Responses
- Route handlers can return a response array containing an HTTP status, headers, and body, or return a Promise.checked 11 Oct 2026
- Response timing
- Routes can respond asynchronously, synchronously, after a delay, or only when manually resolved.checked 4 Oct 2026
- Route methods
- The routing DSL supports GET, PUT, POST, DELETE, PATCH, and HEAD methods.checked 11 Oct 2026
- Support and community
- The project asks community members to follow its Code of Conduct and directs reports to a maintainer.checked 4 Oct 2026
- Support channel
- The project repository provides an Issues page for reporting and discussing issues.checked 11 Oct 2026
- Timing controls
- Routes can respond asynchronously, synchronously, after a delay, or only when manually resolved.checked 11 Oct 2026
- Usage
- The README documents installation with npm or Yarn, direct browser script loading, and importing Pretender as a module.checked 11 Oct 2026
- What it does
- Pretender is a mock server library for XMLHttpRequest and Fetch with an Express- or Sinatra-style syntax for defining routes and handlers.checked 11 Oct 2026
Alternatives to Pretender.js
- 1
Mockzilla
Free planOpen sourceWebAPILinuxmacOS8.1From $10 a month - 2

Beeceptor
Free planWebAPILinuxmacOS7.9From $10 a month - 3
Mockfly
Free planWebAPIExtensionLinux7.4From €150 a year - 4

Microcks
Free planWebAPIExtensionLinux7.2Free plan - 5
MockAPI
Free planWebAPI7.2From $35 a year - 6
Knockout API
Free planWebAPI7.0From $10 a month
