Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allowing dot notation parsing of post body causes existing tests to fail #1074

@bartaz

Description

@bartaz

Recent version added a change to parse dot notation in post body: 9004e33

API in our project uses dots in params and this change caused our existing tests to fail, because we used to do things like:

api.post(`/path`, { 'ws.op': 'value' })
  .reply(200, { /* something */ }

After some investigation I found out that it was introduced by this commit 9004e33 and that I can fix it by updating our tests to:

api.post(`/path`, { 'ws': { 'op': 'value' } })
  .reply(200, { /* something */ }

Still, it's not good that minor version change is causing existing test to break.

More so, right now parsing body is not consistent with query.
While the body of post requests is parsed with dot notation it seems that query is not, so while we have to break ws.op into nested object in post body we still have to use ws.op as one when mocking query of get requests:

api.get('/path')
   .query({ 'ws.op': 'value' })

It would be good if both are consistent.
And possibly parsing dot notation should be optional/configurable so existing tests can still work in old notation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions