1.0.4 • Published 7 years ago

chai-api v1.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

chai-api

Assertion helper for api testing.

Features

Pre-install

npm install mocha-generators

How to use

require('mocha-generators').install();

const assert = require('chai').assert;
const api = require('chai-api')('http://some/api/url');

describe('API tests', function(){
    it('should get result', function*(){
        const req = {
            body: { data: 'value'}
        };
        const result = yield api('GET', '/some/path', req);
        assert.isOk(result, 'result should be defined');
    });

    it('should return isSuccess true', function*(){
        const req = {
            body: { data: 'value'}
        };
        yield api.success('GET', '/some/path', req);
    });
});

APIs

api(method, path, req)

A generator to do api call.

api.success(method, path, req)

Do api call and assert for result.isSuccess be true.

api.notSuccess(method, path, req)

Do api call and assert for result.isSuccess be false.

ToDo

  • Able to define expected result schema
1.0.4

7 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago