Skip to content

Add async/await examples to documentation #659

@JeremyLoy

Description

@JeremyLoy

I didn't realize until after using this library for a few days that supertest.Test (the return value for .get, .expect etc) extends Promise<Response> after a few generations of inheritance.

This means that you can do the following:

import request from 'supertest'
const response = await request.get('/').expect(200)

One key thing to note is that .end should NOT be called when using async/await

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions