Giter Site home page Giter Site logo

approvals-client's Introduction

Approvals Client

A client-side approvals library for making calls to a running Approvals Server instance. This has a peer dependency on Approvals Server.

Setup

By default, Approvals Client comes preconfigured to connect with Approvals Server without any configuration. The client configuration assumes your connection will be localhost:1338. If this is not how your server is configured, you can create a new configuration:

var approvalsClientConfig = {
    port: 1338, // your port goes here
    host: 'localhost' // your host name goes here
}

This configuration should be made global as the module assumes your configuration will be available at the top-level scope in your browser.

Using Approvals Client in your tests

Approvals client is currently designed to work with Mocha test framework. It will be expanded in the future to work with Jasmine (and others). If you want to help expand support, pull requests are gladly accepted.

When writing tests, Approvals Client needs to be initialized with the test framework name. A suggested method is as follows:

describe('My mocha test suite', function () {
    var approvals = approvalsClient('mocha');

    describe('some novel functionality', function () {

        it('should approve my object', function (done) {
            var myObj = {
                foo: 'bar',
                baz: 'quux'
            };

            approvals.verify(JSON.stringify(myObj), this, done);
        });

    });
});

Important note: Verify MUST be called with a string, the test context (this) and a done function. Approvals Client uses the test context to construct file names, so providing the context allows the client to pass values to the server correctly. Mocha's done function is needed because approvals requests are asynchronous and Mocha needs to be alerted when any async behavior is complete.

approvals-client's People

Contributors

cmstead avatar cstead-hunter avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.