@vestaboard/elasticsearch-mocks
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @vestaboard/elasticsearch-mocks

Weekly Downloads

27

Version

1.0.8

License

MIT

Unpacked Size

86 kB

Total Files

38

Last publish

Collaborators

  • johnatvestaboard
  • tysoncadenhead