vendredi 28 avril 2017

How do I use nock to return a default for a path but overwrite that default when I want to?

I'm using nock to mock my api requests in my tests and using persist to set defaults for the requests.

nock('https://myurl.com')
    .persist()
    .get(/api\/endpoint/)
    .reply(200, data)

But I don't always want to reply with data. How would I return other data for a certain request?

Aucun commentaire:

Enregistrer un commentaire