{"id":14981093,"url":"https://github.com/rhythminme/node-es-local","last_synced_at":"2025-07-14T12:36:36.708Z","repository":{"id":65460551,"uuid":"91718715","full_name":"rhythminme/node-es-local","owner":"rhythminme","description":"Downloads and starts a local elasticsearch node for integration testing ","archived":false,"fork":false,"pushed_at":"2019-03-19T11:25:00.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-20T16:57:40.025Z","etag":null,"topics":["elasticsearch","nodejs","testing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhythminme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-18T17:09:13.000Z","updated_at":"2020-09-17T07:40:36.000Z","dependencies_parsed_at":"2023-01-24T14:45:22.623Z","dependency_job_id":null,"html_url":"https://github.com/rhythminme/node-es-local","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rhythminme/node-es-local","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhythminme%2Fnode-es-local","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhythminme%2Fnode-es-local/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhythminme%2Fnode-es-local/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhythminme%2Fnode-es-local/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhythminme","download_url":"https://codeload.github.com/rhythminme/node-es-local/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhythminme%2Fnode-es-local/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265293323,"owners_count":23742276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elasticsearch","nodejs","testing"],"created_at":"2024-09-24T14:02:54.576Z","updated_at":"2025-07-14T12:36:36.665Z","avatar_url":"https://github.com/rhythminme.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-es-local [![CircleCI](https://circleci.com/gh/rhythminme/node-es-local.svg?style=svg\u0026circle-token=394831b277a718b3995f7785fed54b873408752d)](https://circleci.com/gh/rhythminme/node-es-local)\nA simple low-dependency nodejs module that downloads, installs and starts elasticsearch v5.x locally for integration testing. Please note that this module currently only supports elasticsearch v5.x i.e. older versions are not supported.\n\nThe module attempts to download and unzip the package from the [Official Elasticsearch artifacts source](https://artifacts.elastic.co/downloads), if not already downloaded, and starts elasticsearch as a detached nodejs background process listening on the specified port.\n\nTo get started, npm install this module as a dev dependency:\n\n```javascript\nnpm install --save-dev node-es-local\n```\n\nThis module has a single external dependency on the following module for unzipping:\n\n* [adm-zip](https://github.com/cthackers/adm-zip) - a pure Javascript (no-dependency) implementation of zip for nodejs\n\nOnce installed, you can use the module in your mocha tests or within gulp tasks.\n\n## Usage\n\nTo download and start a local instance of elasticsearch:\n\n```javascript\nconst ElasticsearchLocal = require('node-es-local')\n\nconst elasticsearchVersion = '5.2.0'\nconst elasticsearchPort = 9500\nconst cacheDirectory = './.cache'\nconst targetDirectory = './.installs'\n\nnew ElasticsearchLocal(elasticsearchVersion, elasticsearchPort, {\n  cacheDirectory: cacheDirectory,\n  installationDirectory: targetDirectory\n}).start()\n```\n*start()* returns a promise. \n\nTo stop a local instance of elasticsearch started by the previous script:\n\n```javascript\nconst ElasticsearchLocal = require('node-es-local')\n\nconst elasticsearchVersion = '5.2.0'\nconst elasticsearchPort = 9500\nconst cacheDirectory = './.cache'\nconst targetDirectory = './.installs'\n\nnew ElasticsearchLocal(elasticsearchVersion, elasticsearchPort, {\n  cacheDirectory: cacheDirectory,\n  installationDirectory: targetDirectory\n}).stop()\n```\n*stop()* returns a promise.\n\nPort **9200** is the *default port* if not specified and **./.cachedArtifacts** and **./.installs** are the *default cache* and *default installation* directories. Hence, if you are ok with the defaults, the following script is all you need:\n\n```javascript\nconst ElasticsearchLocal = require('node-es-local')\nnew ElasticsearchLocal('5.2.0').start()\n```\n\nSimples!\n\n## Using es-node-local in integration tests\n\nThe following example shows how you can use node-es-local with mocha to start a local instance of elasticsearch for integration tests:\n\n```javascript\nconst ElasticsearchLocal = require('node-es-local')\n\ndescribe('Some feature eg search', () =\u003e {\n  before('given an index with some entries', () =\u003e {\n    return new ElasticsearchLocal('5.2.0').start()  // return the promise\n      .then(() =\u003e {\n        // Put some data in...\n      })\n  })\n\n  after(() =\u003e {\n    return new ElasticsearchLocal('5.2.0').stop() // return the promise\n  })\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhythminme%2Fnode-es-local","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhythminme%2Fnode-es-local","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhythminme%2Fnode-es-local/lists"}