chakram
chakram copied to clipboard
Add ability to programmatically execute tests rather than a network bound request.
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);
});
});
+1
+1
+1
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.
still no solution ?