Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use elastic-mock properly? #26

Open
Artem-Tsymbal opened this issue Apr 19, 2022 · 4 comments
Open

How to use elastic-mock properly? #26

Artem-Tsymbal opened this issue Apr 19, 2022 · 4 comments

Comments

@Artem-Tsymbal
Copy link

"@elastic/elasticsearch": "^8.1.0",
"@elastic/elasticsearch-mock": "^2.0.0",
"jest": "^24.9.0",
Node: v12.22.7

image

console.log(mock.getConnection()) -> [class MockConnection extends BaseConnection]

console.error node_modules/jest-jasmine2/build/jasmine/Env.js:289
  Unhandled error

console.error node_modules/jest-jasmine2/build/jasmine/Env.js:290
  ResponseError: {"error":"Mock not found"}
      at SniffingTransport.request (.../node_modules/@elastic/transport/src/Transport.ts:532:17)
      at Indices.delete (.../node_modules/@elastic/elasticsearch/src/api/api/indices.ts:301:12)
@Artem-Tsymbal
Copy link
Author

Hello, could anybody help me to solve my error

@XOlvl9lK
Copy link

I have the same problem {"error":"Mock not found"}

@wangdrew
Copy link

wangdrew commented Dec 1, 2022

I also got {"error":"Mock not found"} because the mock received a request that doesn't match any resolver function that I set up. In my case, I didn't pay close attention to the fact that my application code was hitting ElasticSearch with a POST request and I had set up the mock resolver with method: 'GET' like in the code examples.

@dimas-cyriaco
Copy link

It would be nice for this error to show what request was made. This way we could more easily create the correct handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants