Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FailureDiffs without configuration #71

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions HaveValidSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ func getDefaultReferenceDirectory(_ sourceFileName: String) -> String {
let folderPathComponents = pathComponents.subarray(with: NSRange(location: 0, length: currentIndex)) as NSArray
let folderPath = folderPathComponents.componentsJoined(by: "/")

setDefaultFailureDiffsDirectory(testTargetFolderPath: folderPath)

return folderPath + "/ReferenceImages"
}

Expand All @@ -111,6 +113,10 @@ private func parseFilename(filename: String) -> String {
return sanitizedName
}

func setDefaultFailureDiffsDirectory(testTargetFolderPath: String) {
setenv("IMAGE_DIFF_DIR", "\(testTargetFolderPath)/FailureDiffs", 0)
}

func sanitizedTestName(_ name: String?) -> String {
guard let testName = currentTestName() else {
fatalError("Test matchers must be called from inside a test block")
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,14 @@ implement the `ViewResizer` protocol and resize yourself.
The custom behavior can be used to record the views too.

For more info on usage, check the [dynamic sizes tests](Bootstrap/BootstrapTests/DynamicSizeTests.swift).

## A note about test failures artifacts

By default Nimble-Snapshot will place test failures image diffs in a folder right next to `ReferenceImages`. It is strongly recommended that you don't commit those files to your source repo.

Add this to your `.gitignore`:

```
# Nimble-Snapshot
FailureDiffs
```
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, good job on the documentation 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should be even more in evidence? I'd put it as a subitem of Use, before Dynamic Type

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'll move it up!