Automated testing of ElasticSearch Nodejs Express

How to implement an automated test for ElasticSearch using Node testing framework?

I want to implement ElasticSearch in my nodejs project for effective search capabilities that uses Express framework, frisby, Socket.io, etc. An implementation of ElasticSearch nodejs is readily available on Google, but not for test automation. Need suggestions.

+6
source share
1 answer

You can use Jasmine or Mocha as test frameworks for Node.js. In test suites you can use another library: superagent .

The superspy allows you to make HTTP requests to the specified URL.

On the other hand, you have elasticsearch that receives HTTP requests.

You may have a dataset library in the form of http requests to publish to elasticsearch. Each dataset will be suitable for submitting elasticsearch to check if the test passes or fails the test.

Here is an example of how a superagent can be used to request 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); }); }); }); 
+5
source

Source: https://habr.com/ru/post/986479/


All Articles