supertest-light
v1.0.3
Published
| Node 7 | [![Build Status](https://travis-ci.org/rook2pawn/supertest-light.svg?branch=master)](https://travis-ci.org/rook2pawn/supertest-light) | Node 8 | [![Build Status](https://travis-ci.org/rook2pawn/supertest-light.svg?branch=master)](https://trav
Downloads
983
Maintainers
Readme
| Node 7 | | Node 8 | | | ------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------- | | Node 9 | | Node 10 | | | Node 11 | | Node 12 | | | Node 13 | | | |
| Code Coverage | | | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
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"
);
});