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

withParams returns a confusing error message when the params do not match #390

Open
nolaneo opened this issue Jun 10, 2019 · 0 comments
Open

Comments

@nolaneo
Copy link

nolaneo commented Jun 10, 2019

We ran into a confusing failure message today when using withParams on a mock.

Our setup was something like this:

mock({
  url: '/users',
  type: 'GET',
}).withParams({
  rightParams: true
});

The test itself failed with a message like:

Pretender intercepted GET /users?rightParams=false but encountered an error: Nothing returned by handler for /users?rightParams=false. Remember to `return [status, headers, body];` in your route handler

Out problem was that it was not immediately obvious that we were calling the endpoint with incorrect params and that it was the withParams which was failing here; it took a while to figure out. (The params we expected were more complex / subtle than the example given! 😄 )

I think withParams should fail with a more explicit errors, maybe something like what assert.deepEqual gives?

expected '/users' to be called with:
{
  rightParams: true,
},
got:
{
  rightParams: false,
}

Here's a branch with an example of this failure: #389

cc @melintercom

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