Socket
Socket
Sign inDemoInstall

@shelf/jest-elasticsearch

Package Overview
Dependencies
107
Maintainers
56
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0 to 5.1.0

1

lib/index.js
"use strict";
var _path = require("path");
module.exports = {

@@ -6,0 +5,0 @@ globalSetup: (0, _path.resolve)(__dirname, './setup.js'),

9

lib/setup.js
"use strict";
var _path = require("path");
var _elasticsearchLocal = require("@shelf/elasticsearch-local");
const cwd = require('cwd');
module.exports = async function startES() {
const config = require((0, _path.resolve)(cwd(), 'jest-es-config.js'))();
module.exports = function startES() {
const path = process.env.JEST_ELASTICSEARCH_CONFIG || (0, _path.resolve)(cwd(), 'jest-es-config.js');
const config = require(path)();
return (0, _elasticsearchLocal.start)(config);
};
"use strict";
var _elasticsearchLocal = require("@shelf/elasticsearch-local");
module.exports = async function stopES() {
module.exports = function stopES() {
(0, _elasticsearchLocal.stop)();
};
{
"name": "@shelf/jest-elasticsearch",
"version": "5.0.0",
"version": "5.1.0",
"description": "Run your tests using jest & elasticsearch-local",

@@ -56,18 +56,18 @@ "keywords": [

"devDependencies": {
"@babel/cli": "7.18.9",
"@babel/core": "7.18.9",
"@babel/cli": "7.19.3",
"@babel/core": "7.20.2",
"@elastic/elasticsearch": "8.4.0",
"@shelf/babel-config": "1.2.0",
"@shelf/eslint-config": "0.19.0",
"@shelf/eslint-config": "2.29.0",
"@shelf/prettier-config": "0.0.7",
"@shelf/tsconfig": "0.0.8",
"@types/cwd": "^0.10.0",
"@types/jest": "28.1.3",
"@types/jest": "28.1.8",
"@types/node": "16",
"eslint": "7.32.0",
"eslint": "8.28.0",
"husky": "7.0.4",
"jest": "28.1.3",
"lint-staged": "12.1.2",
"prettier": "2.3.0",
"typescript": "4.8.2"
"prettier": "2.8.0",
"typescript": "4.8.4"
},

@@ -74,0 +74,0 @@ "engines": {

# jest-elasticsearch
> Jest preset for running tests with local ElasticSearch
>
> [How to mock Elasticsearch with Jest?](https://medium.com/shelf-io-engineering/test-elasticsearch-with-jest-like-a-pro-42386713b899)

@@ -67,2 +69,28 @@ ## Usage

## Monorepo Support
By default the `jest-es-config.js` is read from `cwd` directory, but this might not be suitable for
monorepos with nested [jest projects](https://jestjs.io/docs/configuration#projects-arraystring--projectconfig)
with nested `jest.config.*` files nested in subdirectories.
If your `jest-es-config.js` file is not located at `{cwd}/jest-es-config.js` or you are using
nested `jest projects`, you can define the environment variable `JEST_ELASTICSEARCH_CONFIG` with
the absolute path of the respective `jest-es-config.js` file.
### Example Using `JEST_ELASTICSEARCH_CONFIG` in nested project
```js
// src/nested/project/jest.config.js
const path = require('path');
// Define path of project level config - extension not required as file will be imported
// via `require(process.env.JEST_ELASTICSEARCH_CONFIG)`
process.env.JEST_ELASTICSEARCH_CONFIG = path.resolve(__dirname, './jest-es-config');
module.exports = {
preset: '@shelf/jest-elasticsearch'
displayName: 'nested-project',
};
```
## Troubleshooting

@@ -79,2 +107,3 @@

```
The main reason why this issue appears is that you have an incompatible java version installed to run elastic locally.

@@ -85,2 +114,3 @@

1. List current java versions
```shell

@@ -92,2 +122,3 @@ $ /usr/libexec/java_home -V

Add this command to your bashrc, zshrc, etc
```shell

@@ -98,9 +129,12 @@ $ /usr/libexec/java_home -v 18

3. If you see no versions or do not have a compatible version installed - Install version 18
https://www.oracle.com/java/technologies/downloads/#java18
https://www.oracle.com/java/technologies/downloads/#java18
4. Reload the console and check the java version with
```shell
$ java -version
```
Output for proper work
```shell

@@ -117,3 +151,2 @@ $ java -version

</details>

@@ -123,2 +156,3 @@

- [elasticsearch-local](https://github.com/shelfio/elasticsearch-local)
- [jest-dynamodb](https://github.com/shelfio/jest-dynamodb)

@@ -135,3 +169,5 @@ - [jest-mongodb](https://github.com/shelfio/jest-mongodb)

```
### Create and publish a GitHub release with your tag
1. Go to repository

@@ -143,5 +179,4 @@ 2. Select `Releases`

## License
MIT © [Shelf](https://shelf.io)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc