-
Notifications
You must be signed in to change notification settings - Fork 10
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
Mocking a "scroll" search #16
Comments
Hello! It depends on how you are sending the scroll request. You can either send the // send the scroll_id in the URL
client.scroll({
scroll_id: '<id>',
scroll: '30s'
}, console.log)
// send the scroll_id in the body
client.scroll({
scroll: '30s',
body: {
scroll_id: '<id>'
}
}, console.log) If you want to use the URL params way, the mock should be updated as follows: mock.add({
method: 'GET',
path: '/_search/scroll/:id'
}, () => {
return {
_scroll_id: 'id',
hits: { hits: [] }
}
}) |
@delvedor I gave that a try, but it doesn't seem to quite work... For clarification (using v7.9.1 of Elasticsearch and 0.3.0 of the mocking library), and following the pattern from here. Below is the full test-case.
The result in jest:
|
@abrin you are now passing the scroll_id in the body, so you need to mock the POST method as well. |
changing the mock to allow
|
You must add the POST method to the scroll endpoint mock :) |
Ok! got it... for posterity, and in case it's useful... here's the final constructed test before I cleanup and add local functionality. Thanks!
|
Hi,
I really appreciate the mocking library, I've been trying to mock a scroll request... To test it, I want to return the
_scroll_id
. But, when I include it, I get the error below. Wondering if someone can either point me at an example of how to mock this, or suggest a way forward?Here's how I'm trying to send the mock in
The text was updated successfully, but these errors were encountered: