Clearing & Resetting
To clear all expectations and all request logs (without restarting) use reset as follows:
Java
new MockServerClient("localhost", 1080).reset()
JavaScript
mockServerClient("localhost", 1080).reset();
Ruby
client = MockServerClient.new('localhost', 1080)
client.reset()
To clear only specific expectations or only specific request logs use clear as follows:
Java
The following code clears both exceptions and request logs, however as shown below it is also possible to only clear exceptions or request logs.
new MockServerClient("localhost", 1080).clear(
request()
.withMethod("GET")
.withPath("/somePath")
);
To specify whether to clear exceptions, request logs or both use the type parameter. If no type parameter is specified both expectations and request logs are cleared. The following example shows how to only clear request logs.
new MockServerClient("localhost", 1080).clear(
request()
.withMethod("GET")
.withPath("/somePath"),
MockServerClient.TYPE.LOG
);
JavaScript
The following code clears both exceptions and request logs, however as shown below it is also possible to only clear exceptions or request logs.
mockServerClient("localhost", 1080).clear('/somePath');
To specify whether to clear exceptions, request logs or both use the type parameter. If no type parameter is specified both expectations and request logs are cleared. The following example shows how to only clear request logs.
mockServerClient("localhost", 1080).clear('/somePath', 'log');
Ruby
client = MockServerClient.new('localhost', 1080)
client.clear(request(:GET, '/somePath'))