Skip to content

Commit f6a7c39

Browse files
author
Zip Random
committed
add "I clear the Api Log" step
1 parent 587c1d9 commit f6a7c39

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/api_mock_steps.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ module.exports = function() {
2121
self.startMocking(strict);
2222
});
2323

24+
this.Then(/^I clear the Api Log$/, function () {
25+
client.execute(function() {
26+
return require('xhr-mock').clearLog();
27+
});
28+
});
29+
2430
this.Given(/^I load prerecorded mocks from "([^"]*)"$/, function(path) {
2531
var absolutePath = process.cwd() + "/" + path;
2632
// use map & Object.assign to make a copy

lib/mocking_facility.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,13 @@ module.exports = function() {
470470
return MockXMLHttpRequest._made_requests;
471471
},
472472

473+
/**
474+
* empty the log of requests
475+
*/
476+
clearLog: function() {
477+
MockXMLHttpRequest._made_requests = [];
478+
},
479+
473480
/**
474481
* Mock a request
475482
* @param {string} [method]

0 commit comments

Comments
 (0)