samedi 22 octobre 2016

How to use dynamic variables in sinon url responses?

My query is simple, but I haven't been able to find anything in the sinon documentation. Essentially, I have a profile system that I'm trying to test but I don't want to have to hard code each profile number, nor will they be accessed in any particular order, so I want sinon to capture any url going to a particular place with a number at the end of it. I've tried adding a regex but to no avail. Below is an example of what I mean.

So the profile system will work like this:

http://ift.tt/2ehCGPu
http://ift.tt/2ettuTw

and so on. I've tried the following with sinon.

server.respondWith('GET', '/profile/[0-9]+'

I want sinon to catch anything going to

'/profile/anynumber'

Any ideas?

Aucun commentaire:

Enregistrer un commentaire