6

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.

1
  • I found a solution for this, previously, i used the Mysql database instead of ElasticSearch and wrote functional test cases according to Mysql database. Now when I replaced the Mysql with ElasticSearch, the written test cases should not be fail. I thought that this will be the procedure for testing the elasticsearch that it will not effected our system and it assure that it is correctly implemented Commented May 26, 2015 at 12:10

1 Answer 1

5

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);
        });
    });
});
Sign up to request clarification or add additional context in comments.

3 Comments

I can do the samething using frisby which i have already integrated.
Yes, didn't notice you have frisby available. The methodology is still valid though.
Thanks for the upvote but as you posted the question you can accept the answer by clicking the tick below the upvote/downvote. This acceptance show other users that the answer is valid for you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.