mockhar
v1.0.0
Published
generate fixtures and run a mock server based on an HAR file
Downloads
2
Readme
mockHAR
Helps in generating fixture files from a http archive(HAR) file. It can also spin up mock APIs and websocket endpoints based on the generated fixture file.
Usage
To generate the fixture files alone
- Perform the user action on the website that generates the API request/response pairs or websocket connections and related messages.
- Saved the HAR file from the network tab of the developer tools (assuming you used chrome to perform the user actions mentioned in step 1).
- Run the following command to generate the fixture file from the HAR file you obtained in step 2.
yarn generate-fixtures --file=<mock-file-path> --fixtureName=<fixture-name>
Fixture file structure
{
"httpPack": {
"<request_url_1>": [
{
"response_body": "<response_body>",
"response_headers": "<response_headers>",
"response_status": "<response_status>"
}
],
"<request_url_2>": [
{
"response_body": "<response_body>",
"response_headers": "<response_headers>",
"response_status": "<response_status>"
}
]
},
"wsPack": {
"<ws_url_1>": [
{
"message": "<message>"
}
],
"<ws_url_2>": [
{
"message": "<message>"
}
]
}
}