Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

mockhar

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mockhar

generate fixtures and run a mock server based on an HAR file

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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>"
      }
    ]
  }
}

FAQs

Package last updated on 08 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts