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

Incorrect mocking of req.query. #54

Open
AlexChalk opened this issue Mar 1, 2018 · 0 comments
Open

Incorrect mocking of req.query. #54

AlexChalk opened this issue Mar 1, 2018 · 0 comments

Comments

@AlexChalk
Copy link

AlexChalk commented Mar 1, 2018

If I use superagent and set query to { foo: undefined, bar: [], baz: false, quux: ['a', 'b'] }, superagent-mock generates a req.query object of { foo: 'undefined', bar: '', baz: 'false', quux: 'a,b' }. However, in reality my api receives a query object of { baz: 'false', quux: ['a', 'b'] }.

Steps to reproduce:

  1. Write mock for a superagent request:
  mock.get(...api-address..., (req) => {
    console.log(req.query);
    return { status: 200 };
  });
  1. Write request and verify that { foo: 'undefined', bar: '', baz: 'false', quux: 'a,b' } is logged to console:
request
    .get(`...api-address...`)
    .query({ foo: undefined, bar: [], baz: false, quux: ['a', 'b'] })
  1. Send the request to your server and log req.query, confirm it equals { baz: 'false', quux: ['a', 'b'] }.
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