Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
nock 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 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:

Error: Error: Nock: No match for request {
      "method": "OPTIONS",
   "url": "https://app.launchdarkly.com/sdk/goals/123123123",
  "headers": {
    "origin": "http://localhost",
    "access-control-request-method": "GET",
    "access-control-request-headers": "X-LaunchDarkly-User-Agent",
    "user-agent": "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/16.5.3",
    "host": "app.launchdarkly.com",
    "content-length": 0
  }
}

nock is not recognizing the pattern if I do (note that I am copying the same pattern as a GET as well)

nock('https://app.launchdarkly.com')
    .persist()
    .defaultReplyHeaders({
        'access-control-allow-origin': '*',
        'access-control-allow-headers': '*',
        'access-control-allow-credentials': 'true',
    })
    .options('/sdk/goals.*$/')
    .reply(200, mockLDExperiments);

or

nock('https://app.launchdarkly.com')
    .persist()
    .defaultReplyHeaders({
        'access-control-allow-origin': '*',
        'access-control-allow-headers': '*',
        'access-control-allow-credentials': 'true',
    })
    .options('/sdk/goals/**/*')
    .reply(200, mockLDExperiments);

or

nock('https://app.launchdarkly.com')
    .persist()
    .defaultReplyHeaders({
        'access-control-allow-origin': '*',
        'access-control-allow-headers': '*',
        'access-control-allow-credentials': 'true',
    })
    .options('/sdk/goals')
    .reply(200, mockLDExperiments);

any idea how to write the correct path matcher so I can allow this segment scenario gets picked up by nock?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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\//)
  ...
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda