Hi,
I can't find a way to reliably delete stubs when I have parallel tests running against the same impostor.
The fundamental problem is the API to
delete a stub takes an index, and those indexes change when an earlier stub is removed. For example,
If 3 tests appended its own stub, then test2 deletes its stub at index 1:
{
"stubs:" [ { ...stub1 }, { ...stub2 }, {...stub3} ]
}
DELETE /imposters/<port>/stubs/1
{
"stubs:" [ { ...stub1 }, {...stub3} ]
}
test3 loses its reference to stub3 since stub3 shifted from index 2 to index 1 (shown in second JSON) . When it tries to delete index 2, it errors. Because the stub indexes changes there is no unique identifier to reference a stub.
It seems like either: (1.) indexes shouldn't shift when deleting a stub or (2.) mountebank should return some hash on
add stub, that can be passed back to delete. Right now, add stub returns entire definition of the imposter, so it's cumbersome to parse and remember the index for each test.
Thanks