javascript - Sinon fakeserver url regexp -
according documentation, sinon fakeserver can use regexp pattern match urls:
server.respondwith(method, urlregexp, response);
i match urls ends foo=1. here attempt:
this.server.respondwith('get', '/foo=1$/', [200, { 'content-type': 'application/json' }, '{ "foo": 1 }']); however, doesn't seem work. regexp wrong, need adjusting it.
you have single quotes around regular expression, sinon treating string (which :).
get rid of single quotes , regular expression , work expected.
this.server.respondwith('get', /foo=1$/, [200, { 'content-type': 'application/json' }, '{ "foo": 1 }']);
see creating regular expression on mdn reference.
Comments
Post a Comment