cmorten / superoak

HTTP assertions for Oak made easy via SuperDeno. 🐿 🦕
https://cmorten.github.io/superoak/
MIT License
121 stars 8 forks source link

Document how to send request body, headers, etc #23

Closed seanaye closed 3 years ago

seanaye commented 3 years ago

Issue

I cannot find any documented way of sending a post request with a body or setting custom headers on the request. According to the docs Test.post(url:string) there is only a url accepted. How should I set headers and post body on request?

Setup:

Details

Please replace this quote block with the details of the feature / bug you wish to be addressed. If it is a bug please do your best to add steps to reproduce.

asos-craigmorten commented 3 years ago

superoak is based on superagent and utilises it's API - check out https://visionmedia.github.io/superagent/#post--put-requests.

E.g.

const request = await superoak(app);

await request.post("/user")
    .set("Content-Type", "application/json")
    .send('{"name":"superoak"}')

This is referenced in the readme: https://github.com/asos-craigmorten/superoak#api

We can look to add some more documentation / examples in the repo as well to aid discoverability.

There also appears to be a bug with the type definitions as the returned class from .post(url: string) should have more than just expectation methods!