0.0.2 • Published 7 years ago
freebees v0.0.2
Free bees :bee:
Inspired by http://frisbyjs.com/, using jest and https://github.com/request/request
npm install freebeesFreebees
    // see https://github.com/request/request
    .get({
        url: "https://jsonplaceholder.typicode.com/comments",
        json: true,
    })
    .expectStatus(200)
    .expectMaxResponseTime(500)
    .expectMaxDownloadTime(1500)
    .expectMaxEndTime(2000) // end time = response + download
    .expectJSONMatchesObject({ id: 1 }, "0") // get first item, can be a path (ie. users.0.name )
    .expectBodyContains("Eliseo@gardner.biz")
    .expectBodyContains(/@sydney.com/)
    .expectBodyToMatchSnapshot()
    .it("expect body should have length 500", ({ body }) => {
        return expect(body.length).toBe(500)
    })getting started
npm install --save freebees jestupdate your package.json's scripts.test value to jest:
{
    "scripts": {
        "test": "jest"
    }
}create a new file http.test.js
var freebees = require("freebees")
const http = freebees.default.http
// or
import { http } from "freebees"
http
    .get({
        url: "https://jsonplaceholder.typicode.com/posts/1",
        json: true,
    })
    .expectHeader("x-powered-by")
    .expectHeaderContains("content-type", "application/json")
    .expectJSONContains("userId")
    .expectJSONMatchesObject({ id: 1 })npm t to run the tests