I am struggling to create a mock for an API that includes dynamic parts in the URL. I attempted to use a regular expression, but it is not functioning as expected.
The URL I am trying to mock is: https://example.com/programs/2fcce6e3-07ec-49a9-9146-fb84fb0105cf/subprogram/0f8ddca8-cf5a-4174-bc75-0928f71a0e87/metrics?activeOnly=false
It should be noted that the IDs after programs and subprograms are variable.
I tried to implement the mock with the following regular expression code snippet, but it was unsuccessful:
const mock = RequestMock()
.onRequestTo('https://example.com/programs/.*/subprogram/.*/metrics?activeOnly=false', { method: 'GET' })
.respond(mockObject, 200, {
'access-control-allow-origin': '*'
});
If anyone could provide assistance with this issue, I would greatly appreciate it.