{"id":13467846,"url":"https://github.com/alexliesenfeld/httpmock","last_synced_at":"2025-05-13T23:10:08.391Z","repository":{"id":40139298,"uuid":"207288123","full_name":"alexliesenfeld/httpmock","owner":"alexliesenfeld","description":"HTTP mocking library for Rust","archived":false,"fork":false,"pushed_at":"2025-05-07T11:04:44.000Z","size":3687,"stargazers_count":587,"open_issues_count":18,"forks_count":51,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T12:22:56.025Z","etag":null,"topics":["http-mocking","mock","mock-server","rust","test","test-framework"],"latest_commit_sha":null,"homepage":"https://httpmock.rs","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexliesenfeld.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"alexliesenfeld"}},"created_at":"2019-09-09T10:55:45.000Z","updated_at":"2025-05-07T11:04:48.000Z","dependencies_parsed_at":"2023-11-19T06:26:43.730Z","dependency_job_id":"d69180bf-027d-4981-8031-d6e3001e1844","html_url":"https://github.com/alexliesenfeld/httpmock","commit_stats":{"total_commits":509,"total_committers":20,"mean_commits":25.45,"dds":0.4047151277013753,"last_synced_commit":"d87ab088fff6c5f2e2aacf8083874f357111b1cd"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexliesenfeld%2Fhttpmock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexliesenfeld%2Fhttpmock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexliesenfeld%2Fhttpmock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexliesenfeld%2Fhttpmock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexliesenfeld","download_url":"https://codeload.github.com/alexliesenfeld/httpmock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254042310,"owners_count":22004898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http-mocking","mock","mock-server","rust","test","test-framework"],"created_at":"2024-07-31T15:01:01.318Z","updated_at":"2025-05-13T23:10:03.368Z","avatar_url":"https://github.com/alexliesenfeld.png","language":"Rust","funding_links":["https://github.com/sponsors/alexliesenfeld"],"categories":["Development tools","Rust","开发工具 Development tools","Mocking Libraries"],"sub_categories":["Testing","测试 Testing"],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg width=\"275\" src=\"https://raw.githubusercontent.com/alexliesenfeld/httpmock/master/assets/logo-dark.svg#gh-dark-mode-only\" alt=\"httpmock Logo\"/\u003e\n\u003cimg width=\"275\" src=\"https://raw.githubusercontent.com/alexliesenfeld/httpmock/master/assets/logo-light.svg#gh-light-mode-only\" alt=\"httpmock Logo\"/\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003eSimple yet powerful HTTP mocking library for Rust\u003c/p\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![Build](https://github.com/alexliesenfeld/httpmock/actions/workflows/build.yml/badge.svg)](https://github.com/alexliesenfeld/httpmock/actions/workflows/build.yml)\n[![crates.io](https://img.shields.io/crates/d/httpmock.svg)](https://crates.io/crates/httpmock)\n[![Mentioned in Awesome](https://raw.githubusercontent.com/alexliesenfeld/docs-assets/refs/heads/main/ab.svg)](https://github.com/rust-unofficial/awesome-rust#testing)\n[![Rust](https://img.shields.io/badge/rust-1.81%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1700-2023-06-01)\n\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://httpmock.rs\"\u003eWebsite\u003c/a\u003e\n    ·\n    \u003ca href=\"https://docs.rs/httpmock/\"\u003eAPI Reference\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/alexliesenfeld/httpmock/discussions\"\u003eForum\u003c/a\u003e\n    ·\n    \u003ca href=\"https://crates.io/crates/httpmock\"\u003eCrate\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/alexliesenfeld/httpmock/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/alexliesenfeld/httpmock/issues\"\u003eRequest Feature\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/sponsors/alexliesenfeld\"\u003eSupport this Project\u003c/a\u003e\n\u003c/p\u003e\n\n\n## Features\n\n* Mocks responses from HTTP services\n* Simple, expressive, fluent API.\n* Many built-in helpers for easy request matching ([Regex](https://docs.rs/regex/), JSON, [serde](https://crates.io/crates/serde), cookies, and more).\n* Record and Playback third-party services\n* Forward and Proxy Mode\n* HTTPS support\n* Fault and network delay simulation.\n* Custom request matchers.\n* Standalone mode with an accompanying [Docker image](https://hub.docker.com/r/alexliesenfeld/httpmock).\n* Helpful error messages\n* [Advanced verification and debugging support](https://alexliesenfeld.github.io/posts/mocking-http--services-in-rust/#creating-mocks) (including diff generation between actual and expected HTTP request values)\n* Parallel test execution.\n* Fully asynchronous core with synchronous and asynchronous APIs.\n* Support for [mock configuration using YAML files](https://github.com/alexliesenfeld/httpmock/tree/master#file-based-mock-specification).\n\n## Getting Started\n\nAdd `httpmock` to `Cargo.toml`:\n\n```toml\n[dev-dependencies]\nhttpmock = \"0.8.0-alpha.1\"\n```\n\nYou can then use `httpmock` as follows:\n\n```rust\nuse httpmock::prelude::*;\n\n// Start a lightweight mock server.\nlet server = MockServer::start();\n\n// Create a mock on the server.\nlet mock = server.mock(|when, then| {\n    when.method(GET)\n        .path(\"/translate\")\n        .query_param(\"word\", \"hello\");\n    then.status(200)\n        .header(\"content-type\", \"text/html; charset=UTF-8\")\n        .body(\"hola\");\n});\n\n// Send an HTTP request to the mock server. This simulates your code.\nlet response = isahc::get(server.url(\"/translate?word=hello\")).unwrap();\n\n// Ensure the specified mock was called exactly one time (or fail with a\n// detailed error description).\nmock.assert();\n\n// Ensure the mock server did respond as specified.\nassert_eq!(response.status(), 200);\n```\n\nThe above example will spin up a lightweight HTTP mock server and configure it to respond to all `GET` requests\nto path `/translate` with query parameter `word=hello`. The corresponding HTTP response will contain the text body\n`hola`.\n\nWhen the specified expectations do not match the received request, `mock.assert()` fails the test with a detailed error description, \nincluding a diff that shows the differences between the expected and actual HTTP requests. Example:\n\n```bash\n0 of 1 expected requests matched the mock specification.\nHere is a comparison with the most similar unmatched request (request number 1):\n\n------------------------------------------------------------\n1 : Query Parameter Mismatch\n------------------------------------------------------------\nExpected:\n    key    [equals]  word\n    value  [equals]  hello-rustaceans\n\nReceived (most similar query parameter):\n    word=hello\n\nAll received query parameter values:\n    1. word=hello\n\nMatcher:  query_param\nDocs:     https://docs.rs/httpmock/0.8.0-alpha.1/httpmock/struct.When.html#method.query_param\n```\n\n# Usage\n\nSee the [official website](http://httpmock.rs) for detailed API documentation.\n\n## Examples\n\nYou can find examples in the\n[`httpmock` test directory](https://github.com/alexliesenfeld/httpmock/blob/master/tests/).\nThe [official website](http://httpmock.rs) and [reference docs](https://docs.rs/httpmock/) also contain _**a lot**_ of examples. \n\n## License\n\n`httpmock` is free software: you can redistribute it and/or modify it under the terms of the MIT Public License.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MIT Public License for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexliesenfeld%2Fhttpmock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexliesenfeld%2Fhttpmock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexliesenfeld%2Fhttpmock/lists"}