Adds some conventions to supertest to make testing HTTP APIs quicker.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.npmignore
.travis.yml
README.md
example
index.js
package.json

README.md

test resources

Build Status

Designed to be used with superagent and koa, makes it easy to write simple assertions about HTTP responses:

describe('when you test a put request', function () {
    var testServer, request;
        
    before(function () {
        var app = koa();
        app.use(bodyParser());
        app.use(router(app));
        
        app.put('/dogs', function * () {
            this.response.body = this.request.body;
            this.status = 201;
        });
            
        return startServer(app).then(function (runningServer) {
            testServer = runningServer;
        });
    })
        
    beforeEach(function () {
        request = superAgent
                        .put(testServer.fullUrl('/dogs'))
                        .send({ name: 'fido' });
    });
        
    after(function (done) {
        testServer.close(done);
    })
        
    it('should pass if your expectations are correct', function () {
        return resourceTest(request)
                        .expectStatus(201)
                        .expectBody({ name: 'fido' })
                        .run(testServer)
    });
});