{"id":16426729,"url":"https://github.com/pulyaevskiy/dart-http-mocks","last_synced_at":"2025-09-02T17:45:35.804Z","repository":{"id":66297698,"uuid":"50129915","full_name":"pulyaevskiy/dart-http-mocks","owner":"pulyaevskiy","description":"Mocks for dart:io HTTP requests","archived":false,"fork":false,"pushed_at":"2016-03-28T21:58:08.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-07T16:44:17.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pulyaevskiy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2016-01-21T19:05:10.000Z","updated_at":"2016-01-21T22:56:50.000Z","dependencies_parsed_at":"2023-02-20T21:46:03.148Z","dependency_job_id":null,"html_url":"https://github.com/pulyaevskiy/dart-http-mocks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulyaevskiy%2Fdart-http-mocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulyaevskiy%2Fdart-http-mocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulyaevskiy%2Fdart-http-mocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulyaevskiy%2Fdart-http-mocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pulyaevskiy","download_url":"https://codeload.github.com/pulyaevskiy/dart-http-mocks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240594686,"owners_count":19826237,"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":[],"created_at":"2024-10-11T08:10:10.105Z","updated_at":"2025-02-25T03:24:28.422Z","avatar_url":"https://github.com/pulyaevskiy.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mocks for dart:io HTTP requests\n\n[![Build Status](https://img.shields.io/travis-ci/pulyaevskiy/dart-http-mocks.svg?branch=master\u0026style=flat-square)](https://travis-ci.org/pulyaevskiy/dart-http-mocks)\n[![Coverage Status](https://img.shields.io/coveralls/pulyaevskiy/dart-http-mocks.svg?branch=master\u0026style=flat-square)](https://coveralls.io/github/pulyaevskiy/dart-http-mocks?branch=master)\n[![License](https://img.shields.io/badge/license-BSD--2-blue.svg?style=flat-square)](https://raw.githubusercontent.com/pulyaevskiy/dart-http-mocks/master/LICENSE)\n\n\nMocks and special test matchers to simplify testing of HttpRequests\nfrom `dart:io`.\n\n## 1. Usage\n\n```dart\n// file: some_test.dart\nlibrary some_lib.tests;\n\nimport 'dart:io';\nimport 'package:test/test.dart';\nimport 'package:http_mocks/http_mocks.dart';\n\nvoid main() {\n  test('it mocks http requests', () async {\n    var request = new HttpRequestMock(Uri.parse('/hello-world'), 'GET');\n    // Pass it to your HTTP server or whatever else accepting HttpRequest\n    // as an input argument:\n    await yourHttpServer.handle(request);\n\n    // Use provided matchers:\n    expect(request, responseStatus(HttpStatus.OK));\n    expect(request, responseContentType(ContentType.TEXT));\n    expect(request,\n      responseHeaders(containsPair('Access-Control-Allow-Origin', '*')));\n    expect(request, responseBody(contains('Hello world!')));\n    expect(request, responseSent); // makes sure request has been \"closed\".\n  });\n}\n```\n\n## 2. How it works\n\nUnder the hood this library uses\n[mockito](https://pub.dartlang.org/packages/mockito) to create all the mocks.\nAll mocks are available through `HttpRequestMock` so it is possible\nto perform custom expectations or verifications provided by `mockito`\nlibrary.\n\n```dart\nvar request = new HttpRequestMock(Uri.parse('/foo'), 'GET');\nrequest.headersMock; // mock for request's headers\nrequest.responseMock; // mock for HttpResponse\nrequest.responseHeadersMock; // mock for response's headers\n```\n\n## 3. Limitations\n\nCurrent implementation only covers only a subset of all possible use cases,\nthough hopefully the most common ones. This means that not all the expectations\ncan be performed.\n\n* The `HttpHeadersMock` does not support \"multi-value\" headers at\n  this moment (but this can be added in the future).\n* Reading of request body assumes you will use `UTF8.decodeStream()`.\n\nIf you find a use case which is not covered, feel free to create an issue or a\npull request!\n\n## License\n\nBSD-2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpulyaevskiy%2Fdart-http-mocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpulyaevskiy%2Fdart-http-mocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpulyaevskiy%2Fdart-http-mocks/lists"}