sinon icon indicating copy to clipboard operation
sinon copied to clipboard

SinonFakeServer.respondWith not working with query params on 17.0.2

Open 1bberto opened this issue 9 months ago • 0 comments

Describe the bug the respondWith seems to not work when the URL has a ?

To Reproduce Steps to reproduce the behavior:

I have this

const url =  `/api/FakeApi?hash=10101050&fakeData=true&isGet=true`;

const method = 'GET';

const response = [
  status,
  { 'Content-type': 'application/json', ...headers },
  JSON.stringify(body),
];

server.respondWith(method, url, response);

the code is breaking when server.respondWith is being called

the error is

TypeError: Unexpected MODIFIER at 12, expected END
at mustConsume (webpack://my-company/./node_modules/sinon/pkg/sinon-esm.js?:19288:15)
at parse (webpack://sensei/./node_modules/sinon/pkg/sinon-esm.js?:19346:9)
at stringToRegexp (webpack://my-company/./node_modules/sinon/pkg/sinon-esm.js?:19503:27)
at pathToRegexp (webpack://my-company/./node_modules/sinon/pkg/sinon-esm.js?:19581:12)
at Object.respondWith (webpack://my-company/./node_modules/sinon/pkg/sinon-esm.js?:17830:57)

Context (please complete the following information):

  • Sinon version : 17.0.2
  • Runtime: Node v20.11.1, Chrome Headless 124.0.6367.119 (Windows 10)

1bberto avatar May 07 '24 20:05 1bberto