{"id":2118,"url":"https://github.com/venmo/DVR","last_synced_at":"2025-08-06T14:31:48.121Z","repository":{"id":47604387,"uuid":"37695433","full_name":"venmo/DVR","owner":"venmo","description":"Network testing for Swift","archived":false,"fork":false,"pushed_at":"2024-03-26T22:02:33.000Z","size":204,"stargazers_count":650,"open_issues_count":20,"forks_count":86,"subscribers_count":36,"default_branch":"master","last_synced_at":"2024-05-29T12:03:16.718Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://blog.soff.es/network-testing-in-swift-with-dvr","language":"Swift","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/venmo.png","metadata":{"files":{"readme":"Readme.markdown","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":"2015-06-19T01:43:16.000Z","updated_at":"2024-06-18T21:29:57.809Z","dependencies_parsed_at":"2024-06-18T21:29:57.102Z","dependency_job_id":"61887ab5-fb10-4593-964d-0cf6e099de91","html_url":"https://github.com/venmo/DVR","commit_stats":{"total_commits":125,"total_committers":25,"mean_commits":5.0,"dds":0.728,"last_synced_commit":"65beaf91fc0d7a46d4860028d1087ee5dbb8e382"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venmo%2FDVR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venmo%2FDVR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venmo%2FDVR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venmo%2FDVR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/venmo","download_url":"https://codeload.github.com/venmo/DVR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":215780274,"owners_count":15929791,"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-01-05T20:16:04.028Z","updated_at":"2024-08-17T16:31:14.678Z","avatar_url":"https://github.com/venmo.png","language":"Swift","funding_links":[],"categories":["Testing","Libs","Swift","Testing [🔝](#readme)"],"sub_categories":["Other Testing","Testing","Other free courses"],"readme":"# DVR\n\n[![Version](https://img.shields.io/github/release/venmo/DVR.svg)](https://github.com/venmo/DVR/releases)\n![Status](https://travis-ci.org/venmo/DVR.svg?branch=master)\n![Swift Version](https://img.shields.io/badge/swift-4.2-orange.svg)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager/)\n\nDVR is a simple Swift framework for making fake `NSURLSession` requests for iOS,\nwatchOS, and OS X based on [VCR](https://github.com/vcr/vcr).\n\nEasy [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) is the main design goal. The API is the same as `NSURLSession`. `DVR.Session` is a subclass of `NSURLSession` so you can use it as a drop in replacement anywhere. (Currently only data tasks are supported.)\n\n\n## Usage\n\n```swift\nlet session = Session(cassetteName: \"example\")\nlet task = session.dataTask(with: request) { data, response, error in\n    // Do something with the response\n}\n\n// Nothing happens until you call `resume` as you'd expect.\ntask.resume()\n```\n\nThis will playback the `example` cassette. The completion handler exactly the same way it normally would. In this example, DVR will look for a cassette named `example.json` in your test bundle.\n\nIf the recording of the request is missing, it will record and save it to disk. After saving to disk, it will assert with path of the recorded file. This causes the tests to stop so you can add the cassette to your test target and rerun your tests.\n\n\n### Recording Multiple Requests\n\nBy default, a DVR session only records one request. You can record multiple requests in the same cassette if you tell DVR when to start and stop recording.\n\n``` swift\nlet session = Session(cassetteName: \"multiple\")\n\n// Begin recording multiple requests\nsession.beginRecording()\n\nsession.dataTask(with: URLRequest(url: URL(string: \"http://apple.com\")!)) { data, response, error in\n    // Do something with the response\n\n    session.dataTask(with: URLRequest(url: URL(string: \"http://google.com\")!)) { data, response, error in\n        // Do something with the response\n    }.resume()\n\n    // Finish recording multiple requests\n    session.endRecording() {\n        // All requests have completed\n    }\n}.resume()\n```\n\nIf you don't call `beginRecording` and `endRecording`, DVR will call these for your around the first request you make to a session. You can call `endRecording` immediately after you've submitted all of your requests to the session. The optional completion block that `endRecording` accepts will be called when all requests have finished. This is a good spot to fulfill XCTest expectations you've setup or do whatever else now that networking has finished.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenmo%2FDVR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvenmo%2FDVR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenmo%2FDVR/lists"}