Hi team,
I'm trying to write a basic test using PactConsumerSwift. However it is failing when Pact is trying to connect to the server.
```test(): failed - Error setting up pact: Could not connect to the server.```
I tried to change the localhost address as indicated in some fixes, but it didn't work.
Here is my code, I'd be glad to receive your suggestions:
```import Foundation
import PactConsumerSwift
import XCTest
import Hamcrest
class SimulatedSaleIntegration: XCTestCase {
var mockService: MockService?
let apiClient: SimulatedSaleViewModel = SimulatedSaleViewModel()
let successfulSale = Sale(amount: 5000.0, vat: 0.19, tip: 0.15, paymentMethod: "", location: "")
override func setUp() {
super.setUp()
mockService = MockService(provider: "calculator-service", consumer: "Example-app-for-testing")
apiClient.setServer(url: mockService!.baseUrl)
}
override func tearDown() {
super.tearDown()
}
func testGetSuccessfulSimulatedSale() {
mockService!
.uponReceiving("A request to get a simulated sale")
.withRequest(
method: .GET,
path: "/calculator",
query: [...]
)
.willRespondWith(
status: 200,
headers: ["Content-Type": "application/json"],
body: [...]
)
mockService!.run { (testComplete) -> Void in
self.apiClient.getSimulatedSale(sale: self.successfulSale)
assertThat(self.apiClient.simulatedSale?.fee, equalTo(168.34))
testComplete()
}
}
}```
In logs, all I can see is `interactions/verification` request could not being performed
```Task <5AEFFE81-A9B5-4574-9DFB-EE823F7B83B9>.<2> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x6000015ed710 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], uses wifi, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <5AEFFE81-A9B5-4574-9DFB-EE823F7B83B9>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <5AEFFE81-A9B5-4574-9DFB-EE823F7B83B9>.<2>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=
https://0.0.0.0:1234/interactions/verification, NSErrorFailingURLKey=
https://0.0.0.0:1234/interactions/verification, _kCFStreamErrorDomainKey=1}```
Anyone has an idea about this issue?
Thanks in advace :wink: