ElasticSearch Mocks
This is an in-memory ElasticSearch mock library. It currently only supports a small subset of the large ElasticSearch API, but more overrides may be added over time as use-cases come up. The idea is to be able to run in-memory unit tests without needing to interact with the actual ElasticSearch IO. Please note that this is not a replacement for integration or end to end test strategies and edge cases will likely be identified and corrected.
Installation
yarn add @vestaboard/elasticsearch-mocks --dev
or
npm i @vestaboard/elasticsearch-mocks --save-dev
Usage
// Before importing the real ElasticSearch module
import * as elasticSearchMocks from "@vestaboard/elasticsearch-mocks";
jest.mock("@elastic/elasticsearch", () => elasticSearchMocks);
// Profit!
Supported Mocks
So far, we have overrides for the following methods:
count()
delete()
index()
query()
All other methods will currently hit the real ElasticSearch