chakram icon indicating copy to clipboard operation
chakram copied to clipboard

Add ability to programmatically execute tests rather than a network bound request.

Open tjosbon opened this issue 8 years ago • 5 comments

The feature would allow developers to import their server lib and run tests locally without having to fire up a "live" http server. For context, one can look at the feature as it is supported by supertest.

var request = require('supertest');
var server = require('../server/server.js');

describe('Unfiltered item search', function() {
    it('should return all configured items', function (done) {
        request(server)
            .get('/api/qc/items')
            .set('Accept', 'application/json')
            .expect(200)
            .expect(function(res){
                if(!res.body[0].itemNumber) {
                    console.log('it was true');
                    throw new Error('missing itemNumber');
                }
            })
            .end(done);
    });
});

tjosbon avatar Mar 18 '16 18:03 tjosbon

+1

alexhanh avatar Jun 22 '16 10:06 alexhanh

+1

cdm319 avatar Oct 11 '16 13:10 cdm319

+1

quentinfayet avatar Oct 18 '16 13:10 quentinfayet

This is reasonably easy to do with Express already.

var express = require('express')();
exports.start = function () {
    return express.listen(0).address().port;
}

var chakram = require('chakram');
var server = require('./server');
chakram.setRequestDefaults({ baseUrl: 'http://127.0.0.1:' + server.start() });

Our Express servers seem to work fine with Chakram this way.

kenblair avatar Nov 16 '16 19:11 kenblair

still no solution ?

rlataguerra avatar Oct 04 '17 13:10 rlataguerra