diff --git a/HaveValidSnapshot.swift b/HaveValidSnapshot.swift index 66713050..b1297798 100644 --- a/HaveValidSnapshot.swift +++ b/HaveValidSnapshot.swift @@ -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" } @@ -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") diff --git a/README.md b/README.md index a6bc5ffc..eb8fe202 100644 --- a/README.md +++ b/README.md @@ -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 +``` \ No newline at end of file