Add mock request This method allows you to define a mock request with a specific HTTP method and path, along with an optional response object.
Mock object containing request and optional response
HTTP method (GET, POST, etc.)
Request path to match
Optional response object containing status, headers, and body
HTTP status code for the response
Optional headers for the response
Optional body content for the response
Clear history of requests This method clears the recorded history of requests made to the mock server. It removes all entries from the history array and resets the recorder. After calling this method, the history will be empty, and all recorded requests will be discarded.
Destroy smoker server This method stops the smoker server and clears its history.
Get address information of the smoker server This method retrieves the address information of the smoker server, including the port and address. It returns an AddressInfo object if the server is running, or undefined if the server is not started.
AddressInfo | undefined
Get history from mock requests This method retrieves the history of requests made to the mock server. It returns an array of history entries, each containing the mock ID, request details, and optional response data.
Optional
mock_id: stringOptional mock ID to filter history If provided, only history entries matching the mock_id will be returned. If not provided, all history entries will be returned.
Array of history entries
Get all records from all requests This method retrieves all recorded requests made to the mock server. Each record contains the request details, including the identifier, method, path, and any additional context information.
Array of records
Start smoker server This method initializes the smoker server, allowing it to listen for incoming HTTP requests. It sets up the server to handle requests using the provided fetch callback.
Smoker is a mock server for testing HTTP requests and responses. It allows you to record requests, mock responses, and retrieve request history.