supertest icon indicating copy to clipboard operation
supertest copied to clipboard

Test agent is not setting defaults for requests

Open bdharrington7 opened this issue 7 years ago • 5 comments

The agent returned by supertest doesn't apply the saved settings when a request is made:

const supertest = require('supertest')

const request = supertest.agent(app)
                      .set('Content-Type', 'application/json')

const ret = await request.post('/some/api').send('{"some": "JSON"}')
// body is not read as json at the API

It's because there's a line missing that calls the this._setDefault(req) method in the Test Agent

bdharrington7 avatar Jan 17 '19 20:01 bdharrington7

I have this fixed.

I just need to write a test for it before creating a pull request.

ozzywalsh avatar Jan 19 '19 16:01 ozzywalsh

Hello @bdharrington7 & @ozzywalsh,

Thanks for using this package. @ozzywalsh, I'm waiting for you pull request. 🚀

rimiti avatar Jan 19 '19 16:01 rimiti

Hi @rimiti, The PR has been made almost a month ago (still waiting to be merged), when is the next release?

bdharrington7 avatar Feb 14 '19 23:02 bdharrington7

@rimiti As you're still actively making releases, it would be nice if this made it in to the next one :)

bdharrington7 avatar Mar 08 '19 19:03 bdharrington7

Thanks @ozzywalsh and @bdharrington7 for your contribution. This nice feature has been merged and released:

https://github.com/visionmedia/supertest/releases/tag/v4.0.0

🚀

rimiti avatar Mar 09 '19 11:03 rimiti