npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zuuka-framework

v1.0.3

Published

Zuuka is an API testing framework designed to test JSON REST endpoints. The library offers a BDD testing style and fully exploits javascript promises

Downloads

1

Readme

Zuuka

Zuuka is an API testing framework designed to perform end to end tests on JSON REST endpoints.

The library offers a BDD testing style and fully exploits javascript promises - the resulting tests are simple, clear and expressive. zuuka is built on node.js, mocha, chai and request.

Getting Started

Install zuuka

zuuka requires Node.js and npm to be installed. It is available as an npm module. Ideally, zuuka should be added to your testing project's devDependencies. This can be achieved with the following command:

npm install zuuka-framework --save-dev

Writing Tests

zuuka builds on top of the mocha testing framework. As such, the tests follow mocha's BDD style. The following sections introduce the various aspects of writing a zuuka test.

Making Requests

zuuka makes use of the request library and as such boasts a comprehensive request capability. zuuka exposes helper methods for the most common HTTP request verbs. The methods typically require the URL as the first parameter, the request body (if applicable) as the second parameter and any request options as an optional last parameter.

Below is an example of making a HTTP GET request:

var zuuka = require("zuuka-framework");

describe("zuuka", function() {
    it("should offer simple HTTP request capabilities", function () {
        return zuuka.get("http://localhost:9001");
    });
});

Below is an example of making a HTTP POST request:

var zuuka = require("zuuka-framework");

describe("zuuka", function() {
    it("should offer simple HTTP request capabilities", function () {
        return zuuka.post("http://localhost:9001");
    });
});

Testing Responses

zuuka offers a range of HTTP specific assertions which can test the information returned from API requests. zuuka offers a BDD testing style through zuuka's expect interface.

When testing API responses, pass the request promise as an argument into zuuka.expect. This will return an object which exposes the zuuka and Chai assertions. The assertion is performed once the response is received (i.e. the request promise is fulfilled). zuuka assertions return a promise which resolve to a once the test has been performed.

Below is an example of testing the status code of a HTTP GET request:

var zuuka = require("zuuka-framework"),
    expect = zuuka.expect;

describe("zuuka", function() {
    it("should provide HTTP specific assertions", function () {
        var response = zuuka.get("http://localhost:9001/");
        return expect(response).to.have.status(200);
    });
});

In addition to the HTTP specific assertions, zuuka.expect exposes all of Chai's BDD properties and methods. Documentation for the HTTP specific assertions can be seen here.

Waiting

As this library focuses on testing REST APIs, the tests are naturally asynchronous. Mocha has native support for promises, which zuuka exploits. Returning a promise from an it callback will cause the test to wait until the promise resolves before continuing. zuuka's requests and expectations return promises which fulfill to zuuka response objects. These promises can be returned to ensure the test waits for them to complete (as can be seen in the previous two examples).

It is important that tests wait for all requests and assertions to be completed. To help, zuuka includes a wait method. This returns a promise which will be fulfilled once all assertions have been performed. Furthermore, zuuka will fail any tests which do not wait for assertions to complete. Below is a test using the wait method.

var zuuka = require("zuuka-framework"),
    expect = zuuka.expect;

describe("zuuka", function() {
    it("should provide a simple async testing framework", function () {
        var response = zuuka.get("http://localhost:9001/");
        expect(response).to.have.status(200);
        expect(response).not.to.have.header('non-existing-header');
        return zuuka.wait();
    });
});