Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 0aecd89

Browse files
author
Miroslav Bajtoš
committed
helpers: fix usage of mocha contexts
Mocha 1.19 introduced nested contexts, where each `describe` has its own context inheriting from parent's context via prototype. The helper `whenCalledRemotely` was reading `this.url` to allow users to override the url. However, since `whenCalledRemotely` was not clearing `this.url` properly at the end of the test, the override worked for the first request only. Subsequent requests used the same URL as provided in the helper parameters. This commit fixes the problem by changing `this.url = undefined` to `delete this.url`, so that the the sub-sequent calls can access `this.__proto__.url` in the same way as the first call.
1 parent 12d3bad commit 0aecd89

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ _describe.whenCalledRemotely = function(verb, url, cb) {
160160
if(methodForVerb === 'delete') methodForVerb = 'del';
161161

162162
this.http = this.request[methodForVerb](this.url);
163-
this.url = undefined;
163+
delete this.url;
164164
this.http.set('Accept', 'application/json');
165165
if(this.loggedInAccessToken) {
166166
this.http.set('authorization', this.loggedInAccessToken.id);
@@ -170,7 +170,7 @@ _describe.whenCalledRemotely = function(verb, url, cb) {
170170
this.http.end(function(err) {
171171
test.req = test.http.req;
172172
test.res = test.http.res;
173-
test.url = undefined;
173+
delete test.url;
174174
cb();
175175
});
176176
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "Ritchie Martori",
1111
"dependencies": {
1212
"supertest": "~0.9.0",
13-
"mocha": "~1.17.1",
13+
"mocha": "~1.20.1",
1414
"async": "~0.2.10"
1515
},
1616
"peerDependencies": {

0 commit comments

Comments
 (0)