diff --git a/.eslintrc.js b/.eslintrc.js index 0ffbce4..c3927bb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,7 @@ module.exports = { env: { node: true, - es2021: true, + es2022: true, }, extends: [ 'eslint:recommended', diff --git a/README.md b/README.md index c117289..c6bdf8f 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ Jest preset for running tests with local ElasticSearch, OpenSearch and ZincSearc ElasticSearch and OpenSearch relies on Java, please make sure you have Java installed and `JAVA_HOME` is set. +`jest-search` provide two ways to set up, one is two set up globally, another is running in specific test only + +### set up globally **1. install library** ```bash @@ -138,8 +141,29 @@ beforeAll(async () => { await saveBook(mockBook); }); ``` +### specific test only +the step 1 and 2 are the same as above, `jest-search` export two methods `startEngine` and `stopEngine` to start and stop the search engine, you can manually call them in your test file, the `startEngine` accepts same argument object as defined in `jest-search-config.js` file +```typescript +import { startEngine, stopEngine } from '@geek-fun/jest-search'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +import loadConfig from '../jest-search-config.js'; + + +describe('integration test for elasticsearch', () => { + beforeAll(async () => { + await startEngine(loadConfig()); + await saveBook(mockBook); + }); + afterAll(async () => { + await stopEngine(); + }); + it('should get book when search with valid book name', async () => { + // ... + }); +}); - +``` ### Known issues diff --git a/package-lock.json b/package-lock.json index 75e53f6..cde5c17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@geek-fun/jest-search", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@geek-fun/jest-search", - "version": "1.0.2", + "version": "1.0.3", "license": "MIT", "dependencies": { "debug": "^4.3.4", @@ -3067,9 +3067,9 @@ } }, "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -3821,9 +3821,9 @@ } }, "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" diff --git a/package.json b/package.json index 67b6bab..3db6238 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@geek-fun/jest-search", - "version": "1.0.2", + "version": "1.0.3", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", "description": "Jest preset for running tests with local search platform",