Skip to content

Refactor tests to use abstration around server and client setup for integration tests #180

Description

@jfhbrook

Via @mk-pmb :

I think a good solution would be to refactor a lot of these patterns into a test helper module (maybe setup-loopback-listen):

  • Find a random port (retry on EADDRINUSE), or get an OS-assigned address (demo below)
  • If given just options instead of an ecstatic instance, create one with these options. (Might be abstracted to support other (req, res) handlers or middleware.)
  • Configure events and listen. When listening:
    • Lookup port if set by OS
    • Provide a pre-configured instance of request, and the base URL where the ecstatic instance is listening. (Also refs to the server and the ecstatic instance. The latter because a subsequent test shouldn't have to know whether if was supplied or created with options.)

See: #175

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions