App Simulator
A REST/WebSocket application simulator for integration testing. Isolate your application during automated testing by simulating its dependencies.
Features
- Simulate your external REST dependencies with a simple javascript configuration
- Each simulated endpoint can be updated and reset at runtime
- Each simulated endpoint tracks requests it receives
- A built-in UI for updating/resetting simulators
- Simulate active WebSocket connections
Example
$ npm install --save-dev app-simulators
// simulator.jsconst createSimulators = ; const simulators = ; simulators;
$ node simulator.js
With the simulators running, configure your app's environment to point to the simulators. Each simulator is mounted to /simulators/<PATH>
:
$ USERS_SERVICE=http://localhost:8080/simulators/users DYNAMIC_SERVICE=http://localhost:8080/simulators/dynamic/service ./run-my-app.sh
REST API
The following API can be used to alter/interact with the simulators at runtime.
Cross-Simulator API
GET /api/simulators
Returns a list of running simulators. This is used to build the UI.
DELETE /api/reset-all
Resets all requests and responses for all running simulators.
HTTP Simulator API
Each configured HTTP Simulator has the following interface for updating the simulators once they are running.
Returns a list of requests the simulator received in order of
Deletes the requests received for that simulator.
Gets the current response for the simulator (without including the request in the GET /api/requests/<METHOD>/<PATH>
response).
Sets the response for the simulator. Keys left out of the payload will not be updated.
Note that the "status" and "headers" will not be updated by this request.
Reset the simulator back its original behavior.
WebSocket Simulators
Each configured WebSocket Simulator has the following interface for updating the simulators once they are running.
Returns the socket messages received.
?to=
POST /api/messages/Send the post body as a socket message to the specified socket ID. If the to
parameter is not included, the message is broadcast to all active connections for the given
Resets the socket messages received.
Returns a list of UUID's for the currently connected clients.
Changelog
- 0.1.0
- API test coverage
- Example app
- Bare bones UI
- README.md