How to implement automated test for ElasticSearch using Node testing framework?
I want to implement ElasticSearch into my nodejs Project for efficient searching abilities, which is using Express framework , frisby, Socket.io etc. ElasticSearch nodejs implementation is easily available on google but not it's automation testing. Need Suggestions.
You can use Jasmine or Mocha as testing frameworks for Node.js. Within the test suites you can use another library: superagent.
Superagent allows you to perform HTTP requests to a specified url.
On the other hand you have an elasticsearch that receives HTTP requests.
You can have a library of data sets in the form of http requests to issue towards elasticsearch. Each data set will be suitable to feed elasticsearch to check wether or not a test passes or fails.
Here is an example of how superagent can be used to issue a request to an elasticsearch server:
var request = require('superagent');
var should = require('should.js');
describe('Your test suite', function () {
it('Should test elasticsearch search', function (done) {
request.get('http://localhost:9002/index/type/_search')
.end(function (err, res) {
should.not.exist(err);
should.exist(res);
});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With