Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(mocha): Wrap it.only with the selenium adapter. (#3512)
Browse files Browse the repository at this point in the history
Fixes #3045. Since mocha 2.4.1, we should be wrapping global.it.only.
  • Loading branch information
heathkit committed Sep 2, 2016
1 parent f23d027 commit 8ca9833
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 1 addition & 6 deletions lib/frameworks/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ exports.run = function(runner, specs) {
global.before = mochaAdapters.before;
global.beforeEach = mochaAdapters.beforeEach;

// The implementation of mocha's it.only uses global.it, so since that has
// already been wrapped we must avoid wrapping it a second time.
// See Mocha.prototype.loadFiles and bdd's context.it.only for more details.
var originalOnly = global.it.only;
global.it = mochaAdapters.it;
global.it.only = global.iit = originalOnly;

global.it.only = global.iit = mochaAdapters.iit;
global.it.skip = global.xit = mochaAdapters.xit;
} catch (err) {
deferred.reject(err);
Expand Down
12 changes: 12 additions & 0 deletions spec/mocha/lib_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ describe('protractor library', function() {
browser.get('index.html');
expect(browser.getTitle()).to.eventually.equal('My AngularJS App');
});

describe('with async tests', function() {
var finished = false;

it('should wait for async operations to finish', function() {
browser.get('index.html').then(() => { finished = true });
});

after('verify mocha waited', function() {
if(!finished) { throw new Error('Mocha did not wait for async!'); }
});
});
});

0 comments on commit 8ca9833

Please sign in to comment.