Giter VIP home page Giter VIP logo

Comments (8)

pgte avatar pgte commented on July 21, 2024 8

I added this experimental feature to v0.14.0:

https://github.com/flatiron/nock#persist

Please reopen this if that doesn't work.

from nock.

lefnire avatar lefnire commented on July 21, 2024

I see.. I didn't quite understand the "used interceptors" bit the first time I read it. I have to re-setup each nock if I've already used it once before.

from nock.

lefnire avatar lefnire commented on July 21, 2024

Incidentally, is there an option that can be passed to disable this behavior? Maybe it's bad testing architecture on my part, but I'm grinding my gears trying to get my tests to work with the "used interceptors" requirement.

from nock.

lefnire avatar lefnire commented on July 21, 2024

For example, I have to call a twitter resource multiple times to break up too many requested objects into multiple GETs. It's called multiple times in the library, and I can't "inject" nock between those calls to re-set that interceptor between each call.

from nock.

sam3k avatar sam3k commented on July 21, 2024

This issue gets me every time when using with Jest. This time, it got me because the url ended up with a comma "," as a result of a dynamic url that can take a join array by comma. Simply checking for the length of the array and ommitting when only one element in the array, solves the issue.

Is there a way to throw a comparison error/warning when the URL does not qualify?

Error: Nock: No match for HTTP request. Make sure URL does not end in "," or "/" etc.
Expected: /my/url?s=sts
Received: /my/url?s=sts,

Update: using with Jest.*

from nock.

gr2m avatar gr2m commented on July 21, 2024

@sam3k could you please create a follow up issue with a test that reproduces the problem? Creating a runkit notebook like https://runkit.com/gr2m/59ff5289617b520016eb98f9 is a big help for us to help you faster, ideally help you to get a pul request going that solves your own problem πŸ‘Œ

from nock.

sam3k avatar sam3k commented on July 21, 2024

@gr2m Sure, that's cool. First time using runkit tbh; hopefully got it right. Here it is: https://runkit.com/sam3k/5a048e1d8658b00011f9e174

Things to note:

  • It will fail when const stocks = ['goog'] and path: '/baz?s=goog,', (Ends with comma)
  • but it will pass when const stocks = ['goog', 'gm'] and path: '/baz?s=goog,gm', (Doesn't end with comma)

from nock.

lock avatar lock commented on July 21, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

from nock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.