{"id":15484876,"url":"https://github.com/dblock/ios-snapshot-test-case-expecta","last_synced_at":"2025-07-04T17:37:16.934Z","repository":{"id":13228981,"uuid":"15913455","full_name":"dblock/ios-snapshot-test-case-expecta","owner":"dblock","description":"Expecta matchers for ios-snapshot-test-case.","archived":false,"fork":false,"pushed_at":"2024-04-10T17:56:03.000Z","size":123,"stargazers_count":93,"open_issues_count":1,"forks_count":24,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-20T21:56:07.998Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","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/dblock.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2014-01-14T19:52:54.000Z","updated_at":"2025-05-15T21:47:22.000Z","dependencies_parsed_at":"2024-06-19T01:51:16.817Z","dependency_job_id":"dc8da25d-afbd-42ee-9afc-c547706db28f","html_url":"https://github.com/dblock/ios-snapshot-test-case-expecta","commit_stats":{"total_commits":102,"total_committers":19,"mean_commits":5.368421052631579,"dds":0.7058823529411764,"last_synced_commit":"1b786fd64d3afde1c9c82d37044956f08021bf0a"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/dblock/ios-snapshot-test-case-expecta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dblock%2Fios-snapshot-test-case-expecta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dblock%2Fios-snapshot-test-case-expecta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dblock%2Fios-snapshot-test-case-expecta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dblock%2Fios-snapshot-test-case-expecta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dblock","download_url":"https://codeload.github.com/dblock/ios-snapshot-test-case-expecta/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dblock%2Fios-snapshot-test-case-expecta/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263589298,"owners_count":23485088,"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-02T05:53:24.849Z","updated_at":"2025-07-04T17:37:16.885Z","avatar_url":"https://github.com/dblock.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Expecta Matchers for FBSnapshotTestCase\n=======================================\n\n[Expecta](https://github.com/specta/expecta) matchers for [ios-snapshot-test-case](https://github.com/facebook/ios-snapshot-test-case).\n\n[![Build and test](https://github.com/dblock/ios-snapshot-test-case-expecta/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/dblock/ios-snapshot-test-case-expecta/actions/workflows/build-and-test.yml)\n\n### Usage\n\nAdd `Expecta+Snapshots` to your Podfile, the latest `FBSnapshotTestCase` will come in as a dependency.\n\n``` ruby\npod 'Expecta+Snapshots'\n```\n\n### App setup\n\nUse `expect(view).to.recordSnapshotNamed(@\"unique snapshot name\")` to record a snapshot and `expect(view).to.haveValidSnapshotNamed(@\"unique snapshot name\")` to check it.\n\nIf you project was compiled with Specta included, you have two extra methods that use the spec hierarchy to generate the snapshot name for you: `recordSnapshot()` and `haveValidSnapshot()`. You should only call these once per `it()` block.\n\nIf you need the `usesDrawViewHierarchyInRect` property in order to correctly render UIVisualEffect, UIAppearance and Size Classes, call `[Expecta setUsesDrawViewHierarchyInRect:NO];` inside `beforeAll`.\n\n``` Objective-C\n#define EXP_SHORTHAND\n#include \u003cSpecta/Specta.h\u003e\n#include \u003cExpecta/Expecta.h\u003e\n#include \u003cExpecta+Snapshots/EXPMatchers+FBSnapshotTest.h\u003e\n#include \"FBExampleView.h\"\n\nSpecBegin(FBExampleView)\n\ndescribe(@\"manual matching\", ^{\n\n    it(@\"matches view\", ^{\n        FBExampleView *view = [[FBExampleView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];\n        expect(view).to.recordSnapshotNamed(@\"FBExampleView\");\n        expect(view).to.haveValidSnapshotNamed(@\"FBExampleView\");\n    });\n\n    it(@\"doesn't match a view\", ^{\n        FBExampleView *view = [[FBExampleView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];\n        expect(view).toNot.haveValidSnapshotNamed(@\"FBExampleViewDoesNotExist\");\n    });\n\n});\n\ndescribe(@\"test name derived matching\", ^{\n\n    it(@\"matches view\", ^{\n        FBExampleView *view = [[FBExampleView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];\n        expect(view).to.recordSnapshot();\n        expect(view).to.haveValidSnapshot();\n    });\n\n    it(@\"doesn't match a view\", ^{\n        FBExampleView *view = [[FBExampleView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];\n        expect(view).toNot.haveValidSnapshot();\n    });\n\n});\n\nSpecEnd\n```\n\n### Approximation support\n\nIf for some reason you want to specify a tolerance for your test, you can use either named or unnamed matchers, where the `tolerance` parameter is a `CGFloat` in the interval `[0, 1]` and it represents the minimum ratio of unmatched points by the total number of points in your snapshot. In the example below, a tolerance of `0.01` means our `view` could be up to `1%` different from the reference image.\n\n``` Objective-C\nexpect(view).to.haveValidSnapshotWithTolerance(0.01);\nexpect(view).to.haveValidSnapshotNamedWithTolerance(@\"unique snapshot name\", 0.01);\n```\n\n### Sane defaults\n\n`EXPMatchers+FBSnapshotTest` will automatically figure out the tests folder, and [add a reference image](https://github.com/dblock/ios-snapshot-test-case-expecta/blob/master/EXPMatchers%2BFBSnapshotTest.m#L84-L85) directory, if you'd like to override this, you should include a `beforeAll` block setting the `setGlobalReferenceImageDir` in each file containing tests.\n\n```\nbeforeAll(^{\n    setGlobalReferenceImageDir(FB_REFERENCE_IMAGE_DIR);\n});\n```\n\n\n### Example\n\nA complete project can be found in [FBSnapshotTestCaseDemo](FBSnapshotTestCaseDemo).\n\nNotably, take a look at [FBSnapshotTestCaseDemoSpecs.m](FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDemoSpecs.m) for a complete example, which is an expanded Specta version version of [FBSnapshotTestCaseDemoTests.m](https://github.com/facebook/ios-snapshot-test-case/blob/master/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDemoTests.m).\n\nFinally you can consult the tests for [ARTiledImageView](https://github.com/dblock/ARTiledImageView/tree/master/IntegrationTests) or [NAMapKit](https://github.com/neilang/NAMapKit/tree/master/Demo/DemoTests).\n\n### License\n\nMIT, see [LICENSE](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdblock%2Fios-snapshot-test-case-expecta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdblock%2Fios-snapshot-test-case-expecta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdblock%2Fios-snapshot-test-case-expecta/lists"}