Git Product home page Git Product logo

Comments (3)

bensmith009988 avatar bensmith009988 commented on June 12, 2024

I want to clarify that this behavior is only seen when the mockHttp.When method is used to mock expectations. The mockHttp.Expect does not exhibit this behavior.

from mockhttp.

richardszalay avatar richardszalay commented on June 12, 2024

Answering from my phone so apologies if I've missed something. I'll try to actually run your example in the next few days.

On the surface it looks like your problem is that your first When could also apply to your second call so it's actually matching it twice.

To fix, do one of:

  1. Put your more specific When (with the offset key) before the original one
  2. Use WithExactQuerystring on your first When so it will not match against the offset key
  3. Use Expect instead of When, since you are expecting them in a specific order

from mockhttp.

richardszalay avatar richardszalay commented on June 12, 2024

As you can see, MockHttp method GetMatchCount cannot properly differentiate between requests that only differ by query parameters.

Also just to clarify, GetMatchCount doesn't do any evaluation of requests against mocked requests - it just reports on what was already matched. The issue here is that the first mocked request is being matched twice (which, as above, is due to the way WithQueryString works vs WithExactQueryString)

From the README

WithQueryString:

Matches on one or more querystring values, ignoring additional values

WithExactQueryString:

Matches on one or more querystring values, rejecting additional values

from mockhttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.