Open TimothyJones opened 7 years ago
I'm trying to find the code that provides that "No interaction found for" message, and this is what I found:
def self.response interaction_mismatch
response = {
message: "No interaction found for #{interaction_mismatch.actual_request.method_and_path}",
interaction_diffs: interaction_mismatch.to_hash
}
[500, {'Content-Type' => 'application/json'}, [response.to_json]]
end
I'm not sure if something in the js is stripping out that extra info, or if it's a ruby thing. Can you post the full logs? Or better yet, fork the pact-js repo and create a running example.
Here's an example of the test output, and here's the pact.log
Can create an example if that doesn't illustrate the problem well enough.
You're right, that is not helpful output. I'm still not sure exactly where the "No interaction found for PATCH /view/0" is being printed from. Can you throw together an executable for me by forking pact-js and modifying one of these https://github.com/pact-foundation/pact-js/tree/master/examples
I'll have a play with it locally if I can find time, or maybe @mefellows can.
Here's an example:
https://github.com/TimothyJones/pact-js/tree/issue-77/examples/issue-77
The output is slightly different, because I used the test runner from one of the other examples, but the error message is the same.
@TimothyJones did you find a reason for the error?
You can tell why the error is happening from the more detailed log file (presuming your log level is configured high enough).
This issue was about improving the error message to include the relevant details from the log - but I don’t think anyone had time to look into it yet.
The error means that the actual request didn’t match the expected one for some reason- but the error suggests (sometimes incorrectly) that the http method and URL weren’t correct.
When an interaction described in the test suite differs from the interaction sent by the client, the summary message is something like:
It's easy to read this as implying that the problem is with the
POST
or the/view/
not matching in the request, when it might be because the request fails to match for other reasons (such as a different body content or headers).Further up, the detailed output says:
I think the incorrect requests line there:
PATCH /view/0 (request body did not match)
would be a better summary than theNo interaction found
message.If there's no easy way to pull a good summary for all the cases that cause
No interaction
, then an easy improvement would be:No interaction found for PATCH /view/ (see detailed output above)
Happy to contribute PRs if it would be helpful.