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

done() not recognised matched requests #657

Closed
thewilkybarkid opened this issue Jun 15, 2023 · 1 comment
Closed

done() not recognised matched requests #657

thewilkybarkid opened this issue Jun 15, 2023 · 1 comment
Labels

Comments

@thewilkybarkid
Copy link

I have a sandbox with a single getOnce matcher like:

{
  url: 'https://example.com/some-page/',
  query: { foo: 'bar' },
}

When a request to https://example.com/some-page/?foo=bar is made it matches successfully.

However, fetch.done() returns false.

I've been able to work around this by changing the matcher to:

{
  url: 'begin:https://example.com/some-page/?',
  query: { foo: 'bar' },
}

fetch.done() then returns true as expected.

thewilkybarkid added a commit to PREreview/prereview.org that referenced this issue Jun 15, 2023
This change uses fetch-mock's 'done' inspection to ensure that it matches the requests as expected to avoid tests passing for the wrong reason (i.e. we didn't mock a response).

I think I've found a bug in fetch-mock where it doesn't recognise that it matched a request when testing a query string independently of the URL. It works as expected when only partially matching the URL.

Refs #976, 047d979, https://www.wheresrhys.co.uk/fetch-mock/#api-inspectiondone, wheresrhys/fetch-mock#657
@wheresrhys wheresrhys added the bug label Jun 15, 2024
@wheresrhys
Copy link
Owner

This is due to the unintuitive, and quite confusing implementation of filtering calls in fetch-mock. I'm working on a new library, @fetch-mock/core, which massively simplifies this, so will not be fixing this bug in fetch-mock

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

No branches or pull requests

2 participants