Registry / http-networking / lws-mock-response

lws-mock-response

JSON →
library2.0.0jsnpmunverified

Middleware for adding mock responses to lws (local-web-server). Current stable version is 2.0.0, released under an active maintenance cycle. It enables offline development by simulating API responses when network services are unavailable. Mocks are defined in reusable modules. Key differentiators: tight integration with lws ecosystem, simple class-based mock definitions, and support for various response types (JSON, etc.). Ideal for frontend developers working offline or testing scenarios.

npm install lws-mock-response
INSTALL
IMPORT
SIG · LWS-MOCK-RESPONSE
L
lws-mock-response
http-networkingjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import lwsMockResponse from 'lws-mock-response'
const lwsMockResponse = require('lws-mock-response')
The package is ESM-only as of v2. Use import syntax.

Creates a mock response module for lws and runs it with the --mocks CLI option. Responds with JSON data for /rivers endpoint.

// Save as mocks.js export default class MockRivers { mocks () { return { route: '/rivers', responses: [ { response: { type: 'json', body: [ { name: 'Volga', drainsInto: 'Caspian Sea' }, { name: 'Danube', drainsInto: 'Black Sea' }, { name: 'Ural', drainsInto: 'Caspian Sea' }, { name: 'Dnieper', drainsInto: 'Black Sea' } ] } } ] } } } // Then run: ws --mocks mocks.js // curl http://127.0.0.1:8000/rivers
Debug
Known issues
breakingv2.0.0 dropped CommonJS support; all imports must use ESM.
fix
Update imports to use ESM syntax (import lwsMockResponse from 'lws-mock-response').
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using require() to load the package which is ESM-only in v2.
fix
Use import instead of require.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
lws-mock-response — npm install lws-mock-response · libregistry