How to mock an instance of elasticsearch in Node.js?

One possible option is to use proxyquire + sinon combo

Sinon will fake Client:

const FakeClient = sinon.stub();
FakeClient.prototype.create = sinon.stub().returns("your data");
var fakeClient = new FakeClient();
console.log(fakeClient.create()); // -> "your data"

Such fake client can be passed into module under test by injection via proxyquire:

import proxyquire from 'proxyquire';
const index = proxyquire('./your/index/module', {
  'elasticsearch': { Client: FakeClient }
});