pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.

Home Page:https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snapshot adds imported module's name that fails match with reference shapshot

kapitoshka438 opened this issue · comments

Describe the bug
Our project includes several application targets and test target for each of them for environments split purposes. The source code is common for all environments. We import application modules to their test modules through @testable import this way:

#if canImport(App_dev)
@testable import App_dev
#elseif canImport(App_test)
@testable import App_test
#elseif canImport(App_pre)
@testable import App_pre
#endif

So each test scheme imports a corresponding application target module.

However, generated snapshots put app target module name for their class names that make out snapshot tests fail.
Is there a way to disable module names and avoid creating separate reference snapshots for each environment?

Error Message

test_mutate_whenGoToCatalog_withInitialState_shouldSucceed(): failed - Snapshot does not match reference.

ksDiff "/Users/EMiniakhmetov/ostin-ios-app/Ostin/Tests/Resources/Snapshots/Chat/ChatWebViewMutatorTests/ChatWebViewMutatorTests_test_mutate_whenGoToCatalog_withInitialState_shouldSucceed.1.txt" "/Users/EMiniakhmetov/Library/Developer/CoreSimulator/Devices/5797389E-3B79-4513-A77B-1DF77AF31459/data/Containers/Data/Application/EA522DB9-3AD6-47F2-962D-911EB705C061/tmp/ChatWebViewMutatorTests/ChatWebViewMutatorTests_test_mutate_whenGoToCatalog_withInitialState_shouldSucceed.1.txt"

@@ −1,1 +1,1 @@
−[ChatWebViewMutation.setRoutingTarget(Optional(ChatWebViewModuleState.ViewState.RoutingTarget.catalog)), ChatWebViewMutation.setRoutingTarget(nil)]
+[Ostin_test.ChatWebViewMutation.setRoutingTarget(Optional(Ostin_test.ChatWebViewModuleState.ViewState.RoutingTarget.catalog)), Ostin_test.ChatWebViewMutation.setRoutingTarget(nil)]

Environment

  • swift-snapshot-testing version 1.15.1
  • Xcode 15.1
  • Swift 5.9
  • OS: iOS 17.2