Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common/http: expectOne message could be improved #18013

Closed
cexbrayat opened this issue Jul 8, 2017 · 4 comments
Closed

common/http: expectOne message could be improved #18013

cexbrayat opened this issue Jul 8, 2017 · 4 comments
Labels
area: common/http feature Issue that requests a new feature freq2: medium
Milestone

Comments

@cexbrayat
Copy link
Member

I'm submitting a ...


[ ] Regression (behavior that used to work and stopped working in a new release)
[ ] Bug report 
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

A failed test for an HTTP request gives the following message since #17996:

Expected one matching request for criteria "Match URL: http://localhost:9000/api/users?status=PENDING", found none.

which is better, but still quite hard to debug as we have no idea what the actual request was.

Expected behavior

An ideal message would be something like:

Expected one matching request for criteria "Match URL: http://localhost:9000/api/users?status=PENDING", but only received  "http://localhost:9000/api/users?status=ACTIVE".

Please tell us about your environment


Angular version: 4.3.0-rc.0
@priteshacharya
Copy link

Is there any workaround to see the actual request received?

@trotyl
Copy link
Contributor

trotyl commented Oct 28, 2017

@priteshacharya Just call verify method after it. (Likely better in afterEach)

@alxhub alxhub added freq2: medium severity1: confusing feature Issue that requests a new feature labels Nov 29, 2017
@aciccarello
Copy link
Contributor

Verify does not show the request query parameters making mis-matching params very hard to debug.

const requests = open.map(testReq => {
const url = testReq.request.urlWithParams.split('?')[0];
const method = testReq.request.method;
return `${method} ${url}`;
})
.join(', ');
throw new Error(`Expected no open requests, found ${open.length}: ${requests}`);

A simpler debugging message could just find requests where the urls match and show the different params.

Expected one matching request for criteria "Match URL: http://localhost:9000/api/users Param(s): status=PENDING", but received param(s) "status=ACTIVE"

@ngbot ngbot bot added this to the Backlog milestone Jan 23, 2018
@ngbot ngbot bot modified the milestones: Backlog, needsTriage Feb 28, 2018
cexbrayat added a commit to cexbrayat/angular that referenced this issue Nov 8, 2018
… matches

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.
cexbrayat added a commit to cexbrayat/angular that referenced this issue Nov 9, 2018
… matches

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.
cexbrayat added a commit to cexbrayat/angular that referenced this issue Jan 9, 2019
… matches

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.
cexbrayat added a commit to cexbrayat/angular that referenced this issue Jan 9, 2019
… matches

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.
cexbrayat added a commit to cexbrayat/angular that referenced this issue Jan 10, 2019
… matches

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.
cexbrayat added a commit to cexbrayat/angular that referenced this issue Jan 21, 2020
… matches

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.
cexbrayat added a commit to cexbrayat/angular that referenced this issue Jan 22, 2020
… matches

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.
AndrewKushnir pushed a commit to cexbrayat/angular that referenced this issue Jan 30, 2020
… matches

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.
mhevery pushed a commit that referenced this issue Jan 31, 2020
… matches (#27005)

Fixes #18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.

PR Close #27005
sonukapoor pushed a commit to sonukapoor/angular that referenced this issue Feb 13, 2020
… matches (angular#27005)

Fixes angular#18013

Previously it was hard to debug an `expectOne` if the request had no match, as the error message was:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none.

This commit adds a bit more info to the error, by listing the actual requests received:

    Expected one matching request for criteria "Match URL: /some-url?query=hello", found none. Requests received are: POST /some-url?query=world.

PR Close angular#27005
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: common/http feature Issue that requests a new feature freq2: medium
Projects
None yet
Development

No branches or pull requests

6 participants