Scenario Mock Server is a Node.js library for creating highly configurable mock servers driven by user-defined scenarios. Currently stable at version 1.2.0, it is actively maintained with regular minor and patch releases, recently adding features like scenario grouping in the UI and exposing request headers to response functions. Key differentiators include an integrated web UI for dynamic scenario selection, a 'cookie mode' for multi-user isolation allowing each client to manage their own scenario state, and support for parallel testing through custom `sms-scenario-id` and `sms-context-id` headers, which bypass server-side scenario selection for specific requests. It can run as a standalone server or integrate into an existing Express application.
npm install scenario-mock-serverVerified import paths — ran on the pinned version, not inferred.
This example initializes the mock server with two distinct scenarios, 'item' and 'cheese', for the '/api/test-me' endpoint, demonstrating basic setup and scenario definition.
Update `npm install data-mocks-server` to `npm install scenario-mock-server` and change all code references from `data-mocks-server` to `scenario-mock-server`.
If parallel testing with headers is required, do not enable `cookieMode`. If `cookieMode` is necessary, manage scenarios and contexts via the UI or programmatically for individual users/sessions.
Refer to the `scenario-mock-server` documentation for the latest API if migrating from older `data-mocks-server` versions. Review your mock definitions and server setup.
Specify a different port in the `options` object when calling `run()` or `createExpressApp()`, e.g., `{ options: { port: 3001 } }`.Switch to `import { run } from 'scenario-mock-server';` syntax, or ensure your environment is configured for CommonJS modules, or use a build tool to transpile.Verify the scenario ID spelling. Ensure the scenario is correctly defined in the `scenarios` object. If using the UI, select the correct scenario. If using `sms-scenario-id` header, confirm the header value matches an existing scenario group key.
No dependency data recorded yet.