elasticsearch-js-mock icon indicating copy to clipboard operation
elasticsearch-js-mock copied to clipboard

Upgrading of elasticsearch-mock form v1.0 to v2.0

Open ghost opened this issue 3 years ago • 1 comments

Hi, I got a currentNode.createStaticChild is not a function from find-my-way after upgrading to v2.0. Can check if anyone face the same issue as me?

ghost avatar Oct 03 '22 09:10 ghost

Same problem here. We're upgrading from 1 to 2 also.

Only happens for mocking paths with wildcards, like path: "/my-index*/_search"

I want to mock a path with a literal asterisk, but find-my-way is interpreting the asterisk as a wildcard.

https://github.com/delvedor/find-my-way/issues/277 mentions this and suggests a workaround. I'm temporarily using a similar workaround while I work through a bunch of broken tests for various other problems. (Updating from elastic 7.x to 8.x at the same time; many of my errors have nothing to do with this mock module.)

My workaround is to get rid of the wildcard in a couple places, like the add and get methods:

pattern.path = pattern.path.replace(/[*]/g, 'WILDCARD_WORKAROUND');

https://github.com/delvedor/find-my-way/issues/304 might be useful too.

I'll update this comment and/or submit a PR if I come up with anything more elegant or useful.

...

Update: I tried to create a better workaround in elasticsearch-mock, but couldn't come up with anything workable. For now I'm using override in my package.json to force elasticsearch-mock to use an older version of find-my-way:

"overrides": {
    "find-my-way": "4.3.3"
}

joecullinbarracuda avatar Aug 31 '23 13:08 joecullinbarracuda