nock not able to match all path segments for specific string with random segment value for last segment #2302
-
Please avoid duplicates
Reproducible test casehttps://runkit.com/adamchenwei/nock-nock-1076 Nock Version13.1.0 Node Version14.15.1 TypeScript Versionn/a What happened?https://stackoverflow.com/questions/71035635/not-able-to-match-all-path-segments-for-specific-string I tried several approach to match this specific pattern of the url: https://app.launchdarkly.com/sdk/goals/123123123 so the segment has 123123123 will be always changing.also for some reason its making a OPTION call beside another GET call every time. Not sure why and that's likely another story... nock return error like:
nock is not recognizing the pattern if I do (note that I am copying the same pattern as a GET as well)
or
or
any idea how to write the correct path matcher so I can allow this segment scenario gets picked up by nock? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Answered on SO https://stackoverflow.com/a/71053312/823942 Nock supports Regex path matching. It seems you're attempting something similar with globs, however, if a string is provided Nock only does exact matching. Docs For your case, something like this should get you going. nock('https://app.launchdarkly.com')
...
.options(/^\/sdk\/goals\//)
... |
Beta Was this translation helpful? Give feedback.
Answered on SO https://stackoverflow.com/a/71053312/823942
Nock supports Regex path matching. It seems you're attempting something similar with globs, however, if a string is provided Nock only does exact matching. Docs
For your case, something like this should get you going.