From 8ca98339341434fcff500accd34acfe97b5840e1 Mon Sep 17 00:00:00 2001 From: mgiambalvo Date: Fri, 2 Sep 2016 10:34:04 -0700 Subject: [PATCH] fix(mocha): Wrap it.only with the selenium adapter. (#3512) Fixes #3045. Since mocha 2.4.1, we should be wrapping global.it.only. --- lib/frameworks/mocha.js | 7 +------ spec/mocha/lib_spec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/frameworks/mocha.js b/lib/frameworks/mocha.js index b4ed629b6..4dbae5e05 100644 --- a/lib/frameworks/mocha.js +++ b/lib/frameworks/mocha.js @@ -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); diff --git a/spec/mocha/lib_spec.js b/spec/mocha/lib_spec.js index 05246e945..bb2418122 100644 --- a/spec/mocha/lib_spec.js +++ b/spec/mocha/lib_spec.js @@ -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!'); } + }); + }); });