Subito-it / SBTUITestTunnel

Enable network mocks and more in UI Tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

question about app.stubRequests

ponienchen opened this issue · comments

Please help me with the following 2 questions..

(1)
In this example:

    let myApp = SBTUITunneledApplication(bundleIdentifier: "xxx.yyy.zzz")
    myApp.launchTunnel()
    private let request = NetworkRequests()
    let stubId = walmartApp.stubRequests(matching: SBTRequestMatch(url: "httpbin.org"), response: SBTStubResponse(response: ["myKey": "myResponse"], activeIterations: 1))
    
    let result = request.dataTaskNetwork(urlString: "https://httpbin.org/get?param1=val1&param2=val2")
    print(result)

But I am always getting nil for stubId at the call

let stubId = walmartApp.stubRequests(matching: SBTRequestMatch(url: "httpbin.org"), response: SBTStubResponse(response: ["myKey": "myResponse"], activeIterations: 1))

Can you please help me understand what I am missing here ?

(2)
Also, my App is installed as a 3rd party app which will make some network requests when the user visits a specific page or scrolls down to a certain part of the page.

Will I be able to use SBTUITestTunnel to intercept those network requests (api or graphql) and stub the responses ?

Thank you very much!

As long as SBTUITestTunnelServer.takeOff is invoked on the app stubs should work. In your code I see walmartApp which might not have invoked the above initializer.