Iulian Poenaru
11/24/2022, 9:02 AMqueries
but when I try to test a mutation
I’m getting this error:
/Users/ipoe/GitHubRepo/lp-pros-ios/LoanPalKitTests/Pact Tests/PactTests.swift:499: error: -[LoanPalKitTests.PactTests testAcceptTermsMutation] : failed - Test did not complete within 10.0 second timeout! Did you run testCompleted() block?
/Users/ipoe/GitHubRepo/lp-pros-ios/LoanPalKitTests/Pact Tests/PactTests.swift:499: error: -[LoanPalKitTests.PactTests testAcceptTermsMutation] : failed - Failed to verify Pact! Actual request does not match expected interactions...
Reason:
Missing request
Expected:
POST /graphql
Iulian Poenaru
11/24/2022, 9:04 AMTest Suite 'Selected tests' started at 2022-11-24 11:02:15.822
Test Suite 'LoanPalKitTests.xctest' started at 2022-11-24 11:02:15.824
Test Suite 'PactTests' started at 2022-11-24 11:02:15.824
Test Case '-[LoanPalKitTests.PactTests testAcceptTermsMutation]' started.
------ GraphQLOperation requestQuery -----
["query": Optional("mutation AcceptTermsAndConditions($input: ID!) {\n acceptTerms(termsId: $input) {\n __typename\n currentTermsAccepted\n }\n}"), "operationName": Optional("AcceptTermsAndConditions"), "variables": Optional(["input": Optional("TRMS-***")])]
Outgoing ----- AcceptTermsAndConditions ----- HTTPRequest details:
Endpoint: <http://127.0.0.1:4358/graphql>
Additional Headers: [
X-APOLLO-OPERATION-TYPE: mutation,
X-APOLLO-OPERATION-NAME: AcceptTermsAndConditions,
Content-Type: application/json,
X-Client-Metadata: ***,
Authorization: ***,
apollographql-client-version: 1.9.3-1,
apollographql-client-name: com.loanpal.loanpalPros-apollo-ios,
]
Cache Policy: returnCacheDataElseFetch
Operation: LoanPalKit.AcceptTermsAndConditionsMutation
Context identifier: nil
Request variables: ["input": "TRMS-***"]
[iOS App]11:02:16.018 [INFO] Request started ----- AcceptTermsAndConditions -----
------ RequestBodyCreator -----
["operationName": Optional("AcceptTermsAndConditions"), "query": Optional("mutation AcceptTermsAndConditions($input: ID!) {\n acceptTerms(termsId: $input) {\n __typename\n currentTermsAccepted\n }\n}"), "variables": Optional(["input": Optional("TRMS-fdcef7bc-2484-468b-94b8-729a7f06a1e6")])]
/Users/ipoe/GitHubRepo/lp-pros-ios/LoanPalKitTests/Pact Tests/PactTests.swift:499: error: -[LoanPalKitTests.PactTests testAcceptTermsMutation] : failed - Test did not complete within 10.0 second timeout! Did you run testCompleted() block?
/Users/ipoe/GitHubRepo/lp-pros-ios/LoanPalKitTests/Pact Tests/PactTests.swift:499: error: -[LoanPalKitTests.PactTests testAcceptTermsMutation] : failed - Failed to verify Pact! Actual request does not match expected interactions...
Reason:
Missing request
Expected:
POST /graphql
Test Case '-[LoanPalKitTests.PactTests testAcceptTermsMutation]' failed (10.233 seconds).
Test Suite 'PactTests' failed at 2022-11-24 11:02:26.059.
Executed 1 test, with 2 failures (0 unexpected) in 10.233 (10.235) seconds
Test Suite 'LoanPalKitTests.xctest' failed at 2022-11-24 11:02:26.060.
Executed 1 test, with 2 failures (0 unexpected) in 10.233 (10.236) seconds
Test Suite 'Selected tests' failed at 2022-11-24 11:02:26.060.
Executed 1 test, with 2 failures (0 unexpected) in 10.233 (10.238) seconds
Iulian Poenaru
11/24/2022, 9:06 AMmutations
?
Did you guys added support for GraphQL as I see you did for Pact JS?Iulian Poenaru
11/24/2022, 9:07 AMIulian Poenaru
11/24/2022, 9:09 AMfunc testAcceptTermsMutation() {
let operation = AcceptTermsAndConditionsMutation(input: "TRMS-fdcef7bc-2484-468b-94b8-729a7f06a1e6")
PactTests.mockService
.uponReceiving("A request for accepting the terms and conditions")
.given(ProviderState(description: "Accept terms and conditions", params: ["input": "TRMS-fdcef7bc-2484-468b-94b8-729a7f06a1e6"]))
.withRequest(method: .POST, path: "/graphql", query: nil, headers: headers, body: operation.requestQuery().jsonObject)
.willRespondWith(status: 200,
headers: nil,
body:
[
"data": Matcher.SomethingLike(
[
"acceptTerms": Matcher.SomethingLike(
[
"__typename": Matcher.EqualTo("User"),
"currentTermsAccepted": Matcher.SomethingLike(true)
]
)
]
)
]
)
PactTests.mockService.run(timeout: nil) { mockServiceURL, completion in
let graphClient = GraphQLClient(sessionClient: LoanPalURLSessionClient(), url: URL(string: "\(mockServiceURL)/graphql"))
graphClient.executeMutation(operation: operation) { _, error in
completion()
if error != nil {
XCTFail("Accept terms and conditions request failed \(#function)")
}
}
}
}
Iulian Poenaru
11/24/2022, 9:58 AMMarko (IttyBittyApps / pact-swift)
11/24/2022, 11:35 AMIulian Poenaru
11/24/2022, 2:38 PMMarko (IttyBittyApps / pact-swift)
11/24/2022, 9:42 PMPACT_ENABLE_LOGGING
to all
in your scheme for pactswift to be more verbose at what it is doing.
Hopefully that can give you a bit more info on what is happening.Marko (IttyBittyApps / pact-swift)
11/24/2022, 9:44 PMMarko (IttyBittyApps / pact-swift)
12/02/2022, 2:22 AM