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

Open
thewilkybarkid opened this issue Jun 15, 2023 · 0 comments
Open

done() not recognised matched requests #657

thewilkybarkid opened this issue Jun 15, 2023 · 0 comments

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant