Comparing version 0.5.0 to 0.5.1
@@ -0,1 +1,5 @@ | ||
## 0.5.1 - 2016-02-18 | ||
* Fixed `NoSessionIdError` in parallel run | ||
## 0.5.0 - 2016-02-17 | ||
@@ -2,0 +6,0 @@ * Plugin support added |
'use strict'; | ||
var MochaAdapter = require('./mocha-adapter'), | ||
ProxyReporter = require('./proxy-reporter'), | ||
utils = require('q-promise-utils'), | ||
logger = require('../../utils').logger, | ||
QEmitter = require('qemitter'), | ||
@@ -16,3 +14,2 @@ | ||
this._browserAgent = browserAgent; | ||
this._browser = null; | ||
}, | ||
@@ -31,68 +28,10 @@ | ||
_createMocha: function(suiteFile, filterFn) { | ||
var mocha = new MochaAdapter(this._sharedMochaOpts); | ||
mocha.addFile(suiteFile); | ||
this._attachBrowser(mocha.suite); | ||
this._attachTestFilter(mocha.suite, filterFn); | ||
this._listenMochaEvents(mocha); | ||
return mocha; | ||
}, | ||
_attachBrowser: function(suite) { | ||
var _this = this, | ||
savedEnableTimeouts = suite.enableTimeouts(); | ||
suite.enableTimeouts(false); | ||
suite.beforeAll(function() { | ||
return _this._browserAgent.getBrowser() | ||
.then(function(browser) { | ||
_this._browser = browser; | ||
suite.ctx.browser = browser.publicAPI; | ||
}); | ||
}); | ||
suite.afterAll(function() { | ||
return _this._browser | ||
&& _this._browserAgent.freeBrowser(_this._browser) | ||
.catch(function(e) { | ||
logger.warn('WARNING: can not release browser: ' + e); | ||
}); | ||
}.bind(this)); | ||
suite.enableTimeouts(savedEnableTimeouts); | ||
}, | ||
_attachTestFilter: function(suite, shouldRunTest) { | ||
var browser = this._browserAgent.browserId; | ||
listenSuite_(suite); | ||
function listenSuite_(suite) { | ||
suite.on('suite', listenSuite_); | ||
suite.on('test', filterTest_); | ||
} | ||
function filterTest_(test) { | ||
if (!shouldRunTest(test, browser)) { | ||
test.parent.tests.pop(); | ||
} | ||
} | ||
}, | ||
getBrowser: function() { | ||
return this._browser; | ||
}, | ||
_listenMochaEvents: function(mocha, getBrowser) { | ||
mocha.reporter(ProxyReporter, { | ||
browserId: this._browserAgent.browserId, | ||
getBrowser: this.getBrowser.bind(this), | ||
emit: this.emit.bind(this) | ||
}); | ||
return new MochaAdapter(this._sharedMochaOpts, this._browserAgent) | ||
.addFile(suiteFile) | ||
.attachTestFilter(filterFn) | ||
.attachEmitFn(this.emit.bind(this)); | ||
} | ||
}, { | ||
create: function(config, browser) { | ||
return new MochaRunner(config, browser); | ||
create: function(config, browserAgent) { | ||
return new MochaRunner(config, browserAgent); | ||
} | ||
@@ -99,0 +38,0 @@ }); |
'use strict'; | ||
var inherit = require('inherit'), | ||
var ProxyReporter = require('./proxy-reporter'), | ||
logger = require('../../utils').logger, | ||
inherit = require('inherit'), | ||
Mocha = require('mocha'), | ||
@@ -15,6 +17,10 @@ path = require('path'), | ||
module.exports = inherit({ | ||
__constructor: function(opts) { | ||
__constructor: function(opts, browserAgent) { | ||
this._mocha = new Mocha(opts); | ||
this._mocha.fullTrace(); | ||
this.suite = this._mocha.suite; | ||
this._browserAgent = browserAgent; | ||
this._browser = null; | ||
this._attachBrowser(); | ||
}, | ||
@@ -27,8 +33,64 @@ | ||
this._mocha.files = []; | ||
return this; | ||
}, | ||
reporter: function(reporter, opts) { | ||
this._mocha.reporter(reporter, opts); | ||
_attachBrowser: function() { | ||
var savedEnableTimeouts = this.suite.enableTimeouts(); | ||
this.suite.enableTimeouts(false); | ||
this.suite.beforeAll(this._requestBrowser.bind(this)); | ||
this.suite.afterAll(this._freeBrowser.bind(this)); | ||
this.suite.enableTimeouts(savedEnableTimeouts); | ||
}, | ||
_requestBrowser: function() { | ||
return this._browserAgent.getBrowser() | ||
.then(function(browser) { | ||
this._browser = browser; | ||
this.suite.ctx.browser = browser.publicAPI; | ||
}.bind(this)); | ||
}, | ||
_freeBrowser: function() { | ||
return this._browser | ||
&& this._browserAgent.freeBrowser(this._browser) | ||
.catch(function(e) { | ||
logger.warn('WARNING: can not release browser: ' + e); | ||
}); | ||
}, | ||
attachTestFilter: function(shouldRunTest) { | ||
var browser = this._browserAgent.browserId; | ||
listenSuite_(this.suite); | ||
return this; | ||
function listenSuite_(suite) { | ||
suite.on('suite', listenSuite_); | ||
suite.on('test', filterTest_); | ||
} | ||
function filterTest_(test) { | ||
if (!shouldRunTest(test, browser)) { | ||
test.parent.tests.pop(); | ||
} | ||
} | ||
}, | ||
attachEmitFn: function(emit) { | ||
this._mocha.reporter(ProxyReporter, { | ||
getBrowser: this._getBrowser.bind(this), | ||
emit: emit | ||
}); | ||
return this; | ||
}, | ||
_getBrowser: function() { | ||
return this._browser || {id: this._browserAgent.browserId}; | ||
}, | ||
run: function() { | ||
@@ -35,0 +97,0 @@ return q.Promise(this._mocha.run.bind(this._mocha)); |
@@ -24,3 +24,2 @@ 'use strict'; | ||
this._getBrowser = options.reporterOptions.getBrowser; | ||
this._browserId = options.reporterOptions.browserId; | ||
@@ -90,6 +89,6 @@ this._listenEvents(runner); | ||
return _.extend(data, { | ||
sessionId: browser && browser.sessionId, | ||
browserId: this._browserId | ||
sessionId: browser.sessionId, | ||
browserId: browser.id | ||
}); | ||
} | ||
}); |
{ | ||
"name": "hermione", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Tests framework based on mocha and wdio", | ||
@@ -5,0 +5,0 @@ "main": "lib/hermione.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
46454
1
967