Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

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

Open
timoreimann opened this issue Sep 15, 2015 · 3 comments

Comments

@timoreimann
Copy link

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
Copy link

StephenDillon commented Jun 22, 2017

+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
Copy link
Contributor

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
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants