Hi there! Quick question regarding the > Reason...
# pact-swift
o
Hi there! Quick question regarding the
Reason:
Missing request
error I understand that this error can be triggered by not pointing the api client to the mock pact server. Is it possible that the server itself is not up and running? We're checking the request and it seems to be pointing to localhost, therefore presumably to the pact server.
```class PactExampleTest: XCTestCase {
static var mockService = MockService(consumer: "Our-app",
provider: "Our-orders-service",
writePactTo: URL(fileURLWithPath: "/dev/pacts/folder", isDirectory: true))
func testGetUsers() {
PactExampleTest
.mockService
.uponReceiving("A request for orders")
.given(ProviderState(description: "orders exist", params: ["id": "12345"]))
.withRequest(method: .GET, path: "/v1/orders")
.willRespondWith(
status: 200,
headers: nil,
body: ["test": "test"]
)
let apiClient = CloudApi()
let accessTokenProvider = MockAccessTokenProviderType()
apiClient.authenticatedHTTPService = AuthenticatedHTTPService(accessTokenProvider: accessTokenProvider)
PactExampleTest.mockService.run(timeout: 1000) { [unowned self] mockServiceURL, done in
//this makes sure that the apiClient will hit the correct base url (127.0.0.1:<portNumber>) that's provided by mockServiceURL
let cloudEnvironment = mockCloudEnvironment(onlineOrderingURL: mockServiceURL)
let cloudEnvironmentLoader = CloudEnvironmentLoader()
cloudEnvironmentLoader.saveCurrentEnv(cloudEnvironment)
apiClient.retrieveOnlineOrders(forID: "1234") { dict, error in
print("DICT: \(dict)")
print(error)
}
done()
}
}
}```
m
Is the request actually triggering? And is the path of the request /v1/orders? If the path is “close enough” mock server will return a missing request but also provide a close match it got. If it fails with missing request it is usually the case of request not hitting the mock server at all.
Reading this on my mobile so its a bit hard to see… but is done() called before dictionary in response is received by your apiClient?