Skip to content

Commit

Permalink
Support the done callback in Mocha's BDD interface.
Browse files Browse the repository at this point in the history
Fixes issue 7277.
  • Loading branch information
jleyba committed May 26, 2014
1 parent f1d59a0 commit 88f6680
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## v2.43.0-dev

* FIXED: 7277: Support `done` callback in Mocha's BDD interface
* FIXED: 7156: `Promise#thenFinally` should not suppress original error

## v2.42.0
Expand Down
14 changes: 10 additions & 4 deletions javascript/node/selenium-webdriver/testing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* <li>xit
* </ul>
*
* <p>The provided wrappers leverage the webdriver.promise.ControlFlow to
* simplify writing asynchronous tests:
* <p>The provided wrappers leverage the {@link webdriver.promise.ControlFlow}
* to simplify writing asynchronous tests:
* <pre><code>
* var webdriver = require('selenium-webdriver'),
* portprober = require('selenium-webdriver/net/portprober'),
Expand Down Expand Up @@ -80,7 +80,8 @@
* </code></pre>
*/

var flow = require('..').promise.controlFlow();
var promise = require('..').promise;
var flow = promise.controlFlow();


/**
Expand Down Expand Up @@ -124,7 +125,12 @@ function wrapped(globalFn) {
var timeout = this.timeout;
this.timeout = undefined; // Do not let tests change the timeout.
try {
flow.execute(fn.bind(this)).then(seal(done), done);
var testFn = fn.bind(this);
flow.execute(function() {
var done = promise.defer();
promise.asap(testFn(done.reject), done.fulfill, done.reject);
return done.promise;
}).then(seal(done), done);
} finally {
this.timeout = timeout;
}
Expand Down

0 comments on commit 88f6680

Please sign in to comment.