Skip to content

Commit c7a0205

Browse files
elishererFlorent Dubost
authored and
Florent Dubost
committed
Add method to the fixtures' context object (#65)
support checking for example if put or delete for the same url (crud rest apis)
1 parent 5742e47 commit c7a0205

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/superagent-mock.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ module.exports = function (superagent, config, logger) {
139139

140140
const context = {};
141141
try {
142+
const method = this.method.toLocaleLowerCase();
143+
context.method = method;
142144
const fixtures = parser.fixtures(match, this._data, this.header, context);
143145
if (context.cancel === true) {
144146
return oldEnd.call(this, fn); // mocking was cancelled from within fixtures
145147
}
146-
const method = this.method.toLocaleLowerCase();
147148
const parserMethod = parser[method] || parser.callback;
148149
response = parserMethod(match, fixtures);
149150
} catch (err) {

0 commit comments

Comments
 (0)