-
Notifications
You must be signed in to change notification settings - Fork 629
Description
Describe the bug
In the app I'm working on, I've created a test where I want to assert that for a particular view, the bottom navigation bar is in fact hidden. In my view I'm basically using .toolbar(store.condition? .visible : .hidden, for: .tabBar)
. The app works fine but for this test it is not snapshotting correctly. It still shows the toolbar. The weird thing for me is setting store.condition = false
simply does not work for the test (false = hidden), the view does not change at all which is leading me to believe that the .toolbar
view modifier simply doesn't work in the test environment.
To Reproduce
I will write some pseudo code that represents the problem. Basically I have a root view with a child TabView that will show other views. Apologies for not pasting working code.
// The view
RootView {
TabView {
GeometryReaderWithPerceptionTracking {
ChildView1{
}
}
.toolbar(store.condition? .visible : .hidden, for: .tabBar)
.tabItem{}
ChildView2 {}.tabItem{} //
ChildView3 {}.tabItem{}
}
}
Expected behavior
Expectation - The snapshot test will show the view without a bottom navigation bar just like when the app is normally running.
Reality - The snapshot test shows the bottom navigation bar despite the live experience being different.
Screenshots
N/A
Environment
- swift-snapshot-testing version 1.17.5
- Xcode 16.2
- Swift 5
- OS: iOS 16