@alexcardell/bs-supertest

[![CircleCI][ci-badge]][ci-link] [![NPM][npm-badge]][npm-link] [![MIT License][license-badge]][license-link]

Usage no npm install needed!

<script type="module">
  import alexcardellBsSupertest from 'https://cdn.skypack.dev/@alexcardell/bs-supertest';
</script>

README

bs-supertest

CircleCI NPM MIT License

ReasonML bindings for supertest.

Installing

yarn add --dev @alexcardell/bs-supertest

Don't forget to @alexcardell/bs-supertest to the bs-dev-dependencies list in bsconfig.json.

Note: Requires supertest as a peer dependency in package.json (not in bsconfig.json though).

Usage

An example with bs-jest

let message = err =>
  err
  |> Js.Exn.message
  |> Belt.Option.getExn;

testAsync("a test", finish => {
  let app = make(); /* Your Express server */
  app
    |> Supertest.request
    |> Supertest.expectStatus(200)
    |> Supertest.end_(
      fun
      | Ok(_) => finish(pass)
      | Error(err) =>
          message(err) |> fail |> finish
    );
});

See the tests for more examples, and the source for all the bindings.

Contributions

Issues and PRs welcome.