Skip to main content

render_mock_server_binary

Function render_mock_server_binary 

Source
pub fn render_mock_server_binary() -> String
Expand description

Generate the src/main.rs for the standalone mock server binary.

The binary:

  • Reads all *.json fixture files from a fixtures directory (default ../../fixtures).
  • For each fixture that has a mock_response field, registers a route at /fixtures/{fixture_id} returning the configured status/body/SSE chunks.
  • Binds to 127.0.0.1:0 (random port), prints MOCK_SERVER_URL=http://... to stdout, then waits until stdin is closed for clean teardown.

This binary is intended for cross-language e2e suites (WASM, Node) that spawn it as a child process and read the URL from its stdout.