Stubborn Server is a Node.js library designed to create flexible stub servers for development and testing environments. It currently maintains a stable version, 2.0.1, and has a release cadence that addresses dependency updates, bug fixes, and feature enhancements as needed, with major breaking changes typically bundled into new major versions. Its core functionality includes serving static JSON mocks, handling dynamic requests with Express-based handlers, managing an in-memory database with namespace support, and providing mechanisms for aliasing mock responses and defining fallback routes (static files, proxying to other targets, or reusing existing mocks). A key differentiator is its integration with Express, allowing users to attach custom Express middleware and handlers directly, offering significant flexibility over purely configuration-driven mocking solutions. It's well-suited for integration testing and rapid front-end development against evolving APIs.
npm install stubborn-serverVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes and starts a stubborn server instance with a basic configuration, including an example of attaching a custom Express handler. It demonstrates how to define server settings, programmatically start the server, and includes comments on dynamic configuration changes and stopping the server.
Ensure your Node.js environment is version 10 or higher. Upgrade Node.js if necessary.
Refactor your code to create a new `stubbornServer()` instance for each server you intend to run and manage its configuration and lifecycle independently. The `stubbornServer()` call returns a function which must then be invoked `stub = stubbornServer();`.
Always use a current Long Term Support (LTS) version of Node.js with stubborn-server to ensure compatibility and stability.
Use `const stubbornServer = require('stubborn-server');` for importing the library.Always initialize the server with `const stub = stubbornServer();` before calling methods like `stub.start()` or `stub.stop()`.
You need to invoke the imported function to get a server instance: `const stub = require('stubborn-server')();` then `stub.start();`Upgrade your Node.js environment to version 10 or newer (e.g., use `nvm install 16` and `nvm use 16`).
Change your import statement to use CommonJS `require()`: `const stubbornServer = require('stubborn-server');`.No dependency data recorded yet.