Inject custom API mocks on app launch
In order to use custom API response mocks (with special data) we used
start(using: AppConfiguration())
app.replaceValues(
of: [
"result": "NOT_AUTHENTICATED"
],
in: Stub.Authentication.success
)
But API mocked responses were replaced only after next refresh/API call. So as a workaround we had to do additional UI actions like pull to refresh, closing and opening screens again and so on, just to get that API endpoint called again.
This PR adds nicer way to do that by introducing initiationClosure
param to start(using:)
So, now there is a way to do:
start(using: Configuration()) { app in
app.replaceValues(
of: [
"result": "NOT_AUTHENTICATED"
],
in: Stub.Authentication.success
)
}
.loginStep.authenticationStatusIsVisible()
.loginStep.authenticationStatusIs(equal: "NOT_AUTHENTICATED")
Using this closure we get our custom replaced API mocks right after UI Tests launches the app.
To better illustrate that, I have updated example app with few examples.