Skip to content

testlab: add helpers for testing HTTP servers #237

@bajtos

Description

@bajtos
  • Move code from packages/loopback/test/support to packages/testlab

  • Drop Client class in favour of supertest

  • Add helper APIs for setting up server + supertest:

    • Given a LoopBack app, start it on an ephemeral port (listen(0)), wait until it's listening and then return a supertest instance pointing to this server. (This is useful for testing LoopBack apps.)
    • Given a low-level http.Server instance, start it on an ephemeral port (listen(0)), wait until it's listening and then return a supertest instance pointing to this server. (This is useful e.g. for testing SwaggerRouter in isolation.)

    These two helpers should share most of the implementation code.

Background info from #135:

  • Rework tests to use supertest instead of request. Request's interface is already showing limitations, it's time to move to something better while the amount of needed changes is low.
  • Consider adding supertest to testlab, this makes sense when we also add helpers for setting up HTTP server for a loopback app/router and returning a supertest instance connected to that server.

cc @ritch @superkhau

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions