diff --git a/Tests/SnapshotTestingTests/SnapshotsTraitTests.swift b/Tests/SnapshotTestingTests/SnapshotsTraitTests.swift index 7eb35ebf..a3a7ad2f 100644 --- a/Tests/SnapshotTestingTests/SnapshotsTraitTests.swift +++ b/Tests/SnapshotTestingTests/SnapshotsTraitTests.swift @@ -36,7 +36,7 @@ struct SnapshotsTraitTests { #expect(SnapshotTestingConfiguration.current?.record == .all) } - @Suite(.snapshots(diffTool: "diff", record: .failed)) + @Suite(.snapshots(record: .failed, diffTool: "diff")) struct OverrideDiffToolAndRecord { @Test func config() { diff --git a/Tests/SnapshotTestingTests/WithSnapshotTestingTests.swift b/Tests/SnapshotTestingTests/WithSnapshotTestingTests.swift new file mode 100644 index 00000000..b6f6c6f5 --- /dev/null +++ b/Tests/SnapshotTestingTests/WithSnapshotTestingTests.swift @@ -0,0 +1,35 @@ +import XCTest + +@_spi(Internals) @testable import SnapshotTesting + +class WithSnapshotTestingTests: XCTestCase { + func testNesting() { + withSnapshotTesting(record: .all) { + XCTAssertEqual( + SnapshotTestingConfiguration.current? + .diffTool?(currentFilePath: "old.png", failedFilePath: "new.png"), + """ + @− + "file://old.png" + @+ + "file://new.png" + + To configure output for a custom diff tool, use 'withSnapshotTesting'. For example: + + withSnapshotTesting(diffTool: .ksdiff) { + // ... + } + """ + ) + XCTAssertEqual(SnapshotTestingConfiguration.current?.record, .all) + withSnapshotTesting(diffTool: "ksdiff") { + XCTAssertEqual( + SnapshotTestingConfiguration.current? + .diffTool?(currentFilePath: "old.png", failedFilePath: "new.png"), + "ksdiff old.png new.png" + ) + XCTAssertEqual(SnapshotTestingConfiguration.current?.record, .all) + } + } + } +}