Giter Site home page Giter Site logo

Comments (6)

Hiteklife avatar Hiteklife commented on July 21, 2024 1

I just experienced this. It seems specifically typescript related. If I run the example.js file locally, it runs perfectly fine. If I try to
import Mock from '@elastic/elasticsearch-mock';
in any typescript file, I get the above error. I'm using "typescript": "^4.1.3"

from elasticsearch-js-mock.

delvedor avatar delvedor commented on July 21, 2024

Hello! I just tried to reproduce this issue by using the example in the README and the latest version of both libraries and I didn't see any issue.
Is this still happening to you?

from elasticsearch-js-mock.

covertbert avatar covertbert commented on July 21, 2024

I also get the same error when using typescript

from elasticsearch-js-mock.

DaniloOliveira28 avatar DaniloOliveira28 commented on July 21, 2024

I am experiencing the same issue. Someone has some update?

from elasticsearch-js-mock.

DaniloOliveira28 avatar DaniloOliveira28 commented on July 21, 2024

You can reproduce the error if you create the mock with this dir structure

__mocks__
|_@elastic
    |_elasticsearch.ts

import Client from '@elastic/elasticsearch';
import Mock from '@elastic/elasticsearch-mock';

const mock = new Mock()
const client = new Client({
 node: 'http://localhost:9200',
 Connection: mock.getConnection()
})

mock.add({
 method: 'GET',
 path: '/_cat/health'
}, () => {
 return { status: 'ok' }
})

client.cat.health(console.log)

from elasticsearch-js-mock.

Mites-G avatar Mites-G commented on July 21, 2024

I've had this issue to and ended up solving by mocking it like this:

jest.mock('./client', () => ({
  getClient: () => mockedClient,
}))

from elasticsearch-js-mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.