How mock URL with random query parameters

188 views
Skip to first unread message

Marco Antonio Pajares

unread,
Jun 19, 2017, 5:36:38 AM6/19/17
to Sinon.JS

Boris Cavalier

unread,
Jul 10, 2017, 7:24:02 PM7/10/17
to Sinon.JS
You can use a regular expression that would test the accessed url, to do so, you'll need to create filter (check sinonjs documentation FakeXMLHttpRequest FilteredRequest)

anurag gautam

unread,
Sep 22, 2017, 11:45:33 AM9/22/17
to Sinon.JS
Hi @marco ,

try to push dynamic  Query inside document.history.pushstate.

something like 
 
 var url = window.location.href;
    url = url + '?a=value&b=value2';
    window.history.pushState ({}, null, url);

and to reset the push state use following code  : make sure this should be under beforeeach

 beforeEach (function () {

    history.replaceState (null, document.title, location.pathname);

})
Reply all
Reply to author
Forward
0 new messages