Closed kevinwywang closed 3 weeks ago
Did you try
ViewHosting.host(view: sut.environmentObject(FirstEnvironmentObject)
.environmentObject(SecondEnvironmentObject))
?
Ah of course... I should have thought of that, makes a lot of sense.
Just tried it, and it works, thanks for the quick response Alexey!
Hi, I have two EnvironmentObjects I want to inject into a view.
In testing with ViewInspector, I tried injecting both environment objects with the following:
ViewHosting.host(view: sut.environmentObject(FirstEnvironmentObject)
ViewHosting.host(view: sut.environmentObject(SecondEnvironmentObject)
However, I get the error of Possible blockers being missing EnvironmentObjects.
If I comment out the code for the SecondEnvinronmentObject, and only inject the FirstEnvironmentObject the tests will pass and no errors are thrown.
Is there a way for me to inject both of my environment objects?