Is there a good server side javascript based rest API testing framework? [closed]
-
06-06-2021 - |
Pregunta
I would like to test the external endpoints of a rest api written in java but I would like to run tests from javascript for the possibility of sharing js code and maybe the testing framework with our client web application. Is there a good library out there to make this easier so I don't have to reinvent the wheel?
Solución
I use restler as the http client
https://github.com/danwrong/restler
and mocha for TDD/BDD
http://visionmedia.github.com/mocha/
Writing a test is very simple there is almost no boilerplate involved even though it is not actually a framework per se
test('/authenticate service should authenticate user', function(done) {
var myService = service.getLocator().authenticate;
var params = {username: "...", password: "..."};
service.postJson(myService.host, '/authenticate', params, function(data, response) {
data.username.should.eql('...');
done();
});
});
Otros consejos
I haven't tried it yet but the node.js version of VCR https://github.com/elcuervo/vcr.js looks promising.
Although I would just stub the responses if it's not too complex.