supertest-light

1.0.3 • Public • Published
Node 7 Build Status Node 8 Build Status
Node 9 Build Status Node 10 Build Status
Node 11 Build Status Node 12 Build Status
Node 13 Build Status
Code Coverage Coverage Status

supertest-light

supertest-light is

  • an ultra-minimalist take on supertest
  • much smaller
  • and removes idiosyncratic aspects such as expect

.get(path)

const request = require("supertest-light");
const assert = require("assert");
const app = require("express")();
 
app.get("/user/:username/messages", (req, res, next) => {
  assert.equal(req.headers["user-agent"], "Supertest-Light");
  return res.end(`Hello ${req.params.username}!`);
});
 
request(app)
  .set("User-Agent", "Supertest-Light")
  .get("/user/bart/messages")
  .then(res => {
    assert.equal(res.text, "Hello bart!");
  });

.post(path, postData)

const request = require("supertest-light");
const express = require("express");
const assert = require("assert");
 
const app = express();
app.post("/user/:userId/messages", express.json(), (req, res, next) => {
  return res.end(`doubled: ${req.body.num * 2}`);
});
 
request(app)
  .post("/user/a1234/messages?language=en", { num: 34 })
  .then(res => {
    assert.equal(
      res.text,
      "doubled: 68",
      "postData received and text is property assigned to response"
    );
  });

Package Sidebar

Install

npm i supertest-light

Weekly Downloads

32

Version

1.0.3

License

MIT

Unpacked Size

9.42 kB

Total Files

5

Last publish

Collaborators

  • rook2pawn