elasticsearch test node.js code example
Example 1: elasticsearch test node.js
const { Client } = require('@elastic/elasticsearch')
const Mock = require('@elastic/elasticsearch-mock')
const mock = new Mock()
const client = new Client({
node: 'http://localhost:9200',
Connection: mock.getConnection()
})
mock.add({
method: 'GET',
path: '/'
}, () => {
return { status: 'ok' }
})
client.info(console.log)
Example 2: elasticsearch test node.js
npm install @elastic/elasticsearch-mock --save-dev