fetch-mock icon indicating copy to clipboard operation
fetch-mock copied to clipboard

Error Message always the same, even though could be determined what is wrong.

Open k1ln opened this issue 6 months ago • 3 comments

When writing tests and i Provide the wrong body or url in fetch mock the error-message is always the same =>

Error: fetch-mock: No response or fallback rule to cover put to {url}

one could determine if the body or the url is wrong.

Can i implement this?

Kind Regards

Kilian

k1ln avatar May 28 '25 17:05 k1ln

Are you suggesting adding more debug info to the error log, essentially describing in more detail the request which has not been matched?

wheresrhys avatar May 31 '25 15:05 wheresrhys

yes. that would be the proposal. I would give more Debug Info if the body or the url was not matched.

Just open a pull request for this?

k1ln avatar Jun 04 '25 15:06 k1ln

I'm not sure about it as a feature.

  1. The error state only covers a small number of situations where mocks are misconfigured e.g. misconfigured mocks can result in the wrong mock being applied, rather than no mock.
  2. I used to have debug messages dotted all over the library but they added complexity to the code base and were less helpful than just using node's debugging tools to step through code when something unexpected happens

Given that your proposal would only cover one out of many scenarios when things can go wrong, and node has good tools to allow pausing code execution to inspect the values, I think I will leave things as they are.

I'm happy to leave the issue open for a while though to see if anybody else votes for the feature

wheresrhys avatar Jun 09 '25 10:06 wheresrhys

Closing due to inactivity

wheresrhys avatar Oct 23 '25 10:10 wheresrhys