Skip to content

marg51/freebees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Free bees 🐝

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

npm install freebees

screen shot 2017-06-27 at 12 20 50

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()
    .expectBodyToMatchSchema({
        type: "array",
        items: {
            properties: {
                email: { type: "object" },
            },
            required: ["email"],
        },
    })
    .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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published