4

I am new on developing in Node.js, I would like to know if there's a way to have ElasticSearch embedded in a Node.js application for testing purposes or if there's another way to test interaction with ElasticSearch without having an ElasticSearch running instance (mock ?)

1 Answer 1

4

There are no existing mock libraries for Elasticsearch and Node at the moment. If you know exactly what queries you are going to be performing, you could use a mocking library to mock the entire ES client and assert simple behaviors.

What I'd recommend, however, is actually running ES in a development environment for testing. I find that mocking external services is a pretty tricky thing to do in general, and your tests will likely be much more robust / trustworthy if running against an actual instance of the server.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the useful answer @rdegges
There is a package for Node.js, but it has Elasticsearch v.2.4 npmjs.com/package/elasticsearch-mock-js

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.