DiUS / pact-consumer-js-dsl

*DEPRECATED* A Javascript DSL for creating pacts, superceded by Pact JS
https://github.com/pact-foundation/pact-js
Other
56 stars 26 forks source link

interactions with query parameters embedded directly in the URL are considered non-matching #48

Open timoreimann opened 9 years ago

timoreimann commented 9 years ago

Setting up an interaction using a withRequest component as in

myProvider.withRequest({
    method: "get",
    path: "/resource?query=param"
});

leads to a No matching interaction found for GET /resource?query=param error on the mock service end.

However, if I split out the query parameter into a dedicated query property as in

myProvider.withRequest({
    method: "get",
    path: "/resource",
    query: { query: "param" }
});

the interaction is matched successfully.

While it should probably be good practice to separate the path from the query parameter, I think that the mock service should still consider the interaction as matching in this case in order to avoid confusion on the user's end. This seems especially important when employing the more concise syntax

myProvider.withRequest("get", "/resource?query=param")

where a separate object is not required to specify the request.

If making the mock service more flexible in this regards is not an option, then I'd suggest to at least improve the error message because the current one makes it fairly hard to see what the problem is.

StephenDillon commented 7 years ago

+1 for improving at least the error handling on this. The error we get is pretty unhelpful FAILED Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. or sometimes Missing requests: GET /resource?query=param Unexpected requests: GET /resource?query=param

bethesque commented 7 years ago

Yup, that's pretty unhelpful. The mock service should provide an error message or accept the query all in one. I'll raise an issue in the mock service project.

mefellows commented 7 years ago

Note that this project is deprecated and quite old, so we are unlikely to fix this issue, however we will accept any PR's.

My suggestion is to upgrade to https://github.com/pact-foundation/pact-js and use the pact-web module for Karma/Jasmine tests.