From 8f8114b1320bdf4aec967b244394b42902d014ac Mon Sep 17 00:00:00 2001 From: Rumiya Murtazina Date: Mon, 30 Jun 2025 22:41:52 -0700 Subject: [PATCH] Only create the directory if it does not exist --- Sources/SnapshotTesting/AssertSnapshot.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SnapshotTesting/AssertSnapshot.swift b/Sources/SnapshotTesting/AssertSnapshot.swift index 11e76142..a5792d7a 100644 --- a/Sources/SnapshotTesting/AssertSnapshot.swift +++ b/Sources/SnapshotTesting/AssertSnapshot.swift @@ -331,7 +331,9 @@ public func verifySnapshot( snapshotFileUrl = snapshotFileUrl.appendingPathExtension(ext) } let fileManager = FileManager.default - try fileManager.createDirectory(at: snapshotDirectoryUrl, withIntermediateDirectories: true) + if !fileManager.fileExists(atPath: snapshotDirectoryUrl.path) { + try fileManager.createDirectory(at: snapshotDirectoryUrl, withIntermediateDirectories: true) + } let tookSnapshot = XCTestExpectation(description: "Took snapshot") var optionalDiffable: Format?