This repository provides the setup for a local mock server, a browser plugin, and a generator to create mock data for your application. These components work together to simulate responses from a server, which your Chrome extension can consume. Below is an overview of how the system works and how to get everything up and running.
The mock server can be installed and run via the @wesflo/mock-server
package. It listens for requests from the browser plugin and returns a mock JSON response based on the parameters passed.
Install the mock server locally via npm:
npm i @wesflo/mock-server
For easier usage, you can install the mock server globally:
npm install -g @wesflo/mock-server
You can start the mock server using npx
:
npx wf-serve
Or if you’ve installed it globally, you can run it directly:
wf-serve
For more details on the mock server, please refer to the Mock Server README.
The Chrome extension makes HTTP requests to the mock server based on the parameters set by the user. The server then returns mock JSON data that the extension can use to simulate different server responses.
For more details on the browser plugin, please refer to the Browser Plugin README.
The generator is used to create mock JSON files that the mock server will serve in response to requests from the browser plugin. You can customize the data based on your requirements, and the generator ensures that it follows the correct structure for use by the mock server.
For more details on the mock data generator, please refer to the Generator README.
status=200
to=1000
(timeout of 1 second)path=mockData.json
(file path of the mock data)pDir=mock
(directory where mock files are located)The mock server processes the request, reads the file mockData.json
from the mock
directory, and returns the contents as JSON.
By following these steps and using the provided tools, you can simulate various server responses and test your application as if it were communicating with a real backend.
If you encounter any issues or have feature suggestions, feel free to open an issue on https://github.com/wesflo/browser-mock/issues or join the discussion here: https://github.com/wesflo/browser-mock/discussions.