0.0.2 • Published 6 years ago

freebees v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Free bees :bee:

Inspired by http://frisbyjs.com/, using jest and https://github.com/request/request

npm install freebees
Freebees
    // 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 jest

update 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