nemo
Advanced tools
Comparing version 4.11.1 to 4.12.0
module.exports = { | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
"es6": true, | ||
"mocha": true | ||
}, | ||
@@ -6,0 +7,0 @@ |
@@ -0,1 +1,16 @@ | ||
## 4.12.0 | ||
### Breaking Changes | ||
- Updated `chromedriver` dependency to version 81, which requires Node 10 | ||
- Updated minimum requirement to `Node 10` from `Node 8` | ||
### Fix | ||
- Instantiate and injects `nemo` into context on the global `beforeEach` hook when `driverPerTest` is `true` | ||
- Updated dependency to Mocha 7.1.1 since that is the version that fixes start event firing too early, before it can be monitored. https://github.com/mochajs/mocha/issues/2753 | ||
### Feature | ||
- Added `before:root` event | ||
## 4.11.1 | ||
@@ -2,0 +17,0 @@ |
@@ -22,4 +22,3 @@ var Table = require('cli-table'); | ||
console.log(table.toString()); | ||
let zeroExitCode = context.config.get('profiles:base:zeroExitCode') || false | ||
let zeroExitCode = context.config.get('profiles:base:zeroExitCode') || false; | ||
process.exitCode = zeroExitCode ? 0 : Math.min(output.totals.fail, 255); | ||
@@ -26,0 +25,0 @@ if (context.program.exit) { |
@@ -57,7 +57,11 @@ 'use strict'; | ||
if (this.nemo) { | ||
return this.nemo && this.nemo.driver && this.nemo.driver.quit() | ||
.then(function () { | ||
log('destroyNemo: Quit driver'); | ||
return Promise.resolve(); | ||
}); | ||
if (this.nemo.driver) { | ||
log('Quitting nemo driver instance'); | ||
return this.nemo.driver.quit() | ||
.then(function () { | ||
log('destroyNemo: Quit driver'); | ||
return Promise.resolve(); | ||
}); | ||
} | ||
log('Nemo instance does not have a driver to quit'); | ||
} | ||
@@ -81,8 +85,27 @@ } | ||
function beforeRun() { | ||
const Root = runner.suite; | ||
runnerConfig.emitter.emit('root:before'); | ||
log('beforeRun called'); | ||
if (instanceConfig.profile.conf.driverPerTest) { | ||
log('driverPerTest %s', instanceConfig.profile.conf.driverPerTest); | ||
Root.beforeEach(function () { | ||
return createNemo() | ||
.then(bindNemo.bind(this)); | ||
}); | ||
if (Root._beforeEach.length > 0) { | ||
Root._beforeEach.unshift(Root._beforeEach.pop()); | ||
} | ||
Root.afterEach(destroyNemo); | ||
return; | ||
} | ||
} | ||
function beforeSuite(Suite) { | ||
runnerConfig.emitter.emit('suite:before'); | ||
log('suite event, suite %s, root: %s', Suite.title, Suite.root); | ||
if (instanceConfig.profile.conf.driverPerTest) { | ||
log('driverPerTest %s', instanceConfig.profile.conf.driverPerTest); | ||
Suite.beforeEach(function () { | ||
if (!instanceConfig.profile.conf.driverPerTest) { | ||
Suite.beforeAll(function () { | ||
if (Suite.tests.length > 0) { | ||
@@ -94,28 +117,13 @@ return createNemo() | ||
}); | ||
if (Suite._beforeEach.length > 0) { | ||
Suite._beforeEach.unshift(Suite._beforeEach.pop()); | ||
if (Suite._beforeAll.length > 0) { | ||
// add nemo's beforeAll to the FRONT of the beforeAll array | ||
Suite._beforeAll.unshift(Suite._beforeAll.pop()); | ||
} | ||
Suite.afterEach(destroyNemo); | ||
return; | ||
} | ||
// createNemo beforeAll (one nemo per suite) | ||
Suite.beforeAll(function () { | ||
if (Suite.tests.length > 0) { | ||
return createNemo() | ||
.then(bindNemo.bind(this)); | ||
} | ||
return; | ||
}); | ||
if (Suite._beforeAll.length > 0) { | ||
// add nemo's beforeAll to the FRONT of the beforeAll array | ||
Suite._beforeAll.unshift(Suite._beforeAll.pop()); | ||
// afterAll, kill nemo | ||
Suite.afterAll(destroyNemo); | ||
} | ||
// afterAll, kill nemo | ||
Suite.afterAll(destroyNemo); | ||
} | ||
function afterSuite(Evt) { | ||
@@ -147,3 +155,3 @@ runnerConfig.emitter.emit('suite'); | ||
let testCircularSafe = prepareTestResult(test); | ||
runnerConfig.emitter.emit('test:before', testCircularSafe) | ||
runnerConfig.emitter.emit('test:before', testCircularSafe); | ||
} | ||
@@ -196,2 +204,3 @@ function afterEachTest(test, err) { | ||
runner = mocha.run(afterMocha); | ||
runner.on('start', beforeRun); | ||
runner.on('test', beforeEachTest); | ||
@@ -202,2 +211,3 @@ runner.on('pass', afterEachTest); | ||
runner.on('suite end', afterSuite); | ||
return mochaCompletePromise; | ||
@@ -204,0 +214,0 @@ } |
{ | ||
"name": "nemo", | ||
"version": "4.11.1", | ||
"version": "4.12.0", | ||
"description": "Wrapper to run mocha suites with injected selenium-webdriver instance", | ||
@@ -25,3 +25,4 @@ "scripts": { | ||
"nemo:scaffold": "./bin/nemo -B scaffold -P pay,search,form", | ||
"lint": "eslint ./bin/* ./lib/*" | ||
"lint": "eslint ./bin/* ./lib/*", | ||
"reset": "rm -rf node_modules && npm install" | ||
}, | ||
@@ -60,3 +61,3 @@ "repository": { | ||
"cli-table": "^0.3.1", | ||
"commander": "^3.0.0", | ||
"commander": "^4.0.0", | ||
"common-path-start": "0.0.4", | ||
@@ -75,5 +76,5 @@ "debug": "^4.1.1", | ||
"minimist": "^1.2.0", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^6.1.4", | ||
"mochawesome": "^4.0.1", | ||
"mkdirp": "^1.0.0", | ||
"mocha": "^7.1.1", | ||
"mochawesome": "^5.0.0", | ||
"moment": "^2.22.2", | ||
@@ -83,7 +84,7 @@ "nemo-core": "^1.1.3", | ||
"threads": "^0.12.1", | ||
"uuid": "^3.3.2", | ||
"yargs": "^14.0.0" | ||
"uuid": "^7.0.0", | ||
"yargs": "^15.0.1" | ||
}, | ||
"devDependencies": { | ||
"chromedriver": "^77.0.0", | ||
"chromedriver": "^83.0.0", | ||
"eslint": "^6.0.1", | ||
@@ -90,0 +91,0 @@ "eslint-plugin-es6-recommended": "^0.1.2" |
@@ -309,3 +309,3 @@ # nemo | ||
`nemo` creates `mocha` instances programmatically. Unfortunately, not all `mocha` command line options are available when instantiating it this way. One of the arguments that is **not** supported is the `--require` flag, which useful if you want to `require` a module, e.g. `babel-register` for transpilation. Thus, we added a `"require"` property in `config.json`, which takes a string of a single npm module name, or an array of npm module names. If it is an array, `nemo` will `require` each one before instantiating the `mocha` instances. | ||
`nemo` creates `mocha` instances programmatically. Unfortunately, not all `mocha` command line options are available when instantiating it this way. One of the arguments that is **not** supported is the `--require` flag, which useful if you want to `require` a module, e.g. `babel-register` (for Babel v6) or `@babel/register` (for Babel v7) for transpilation. Thus, we added a `"require"` property in `nemo.config.json` profile/base/mocha block, which takes a string of a single npm module name, or an array of npm module names. If it is an array, `nemo` will `require` each one before instantiating the `mocha` instances. | ||
@@ -333,2 +333,6 @@ ## Events | ||
### `root:before` | ||
This event is published when root suite execution started | ||
### `suite:before` | ||
@@ -436,4 +440,5 @@ | ||
``` | ||
When `driverPerSuite` is `true` the global `beforeEach` hook will have a `nemo` instance injected, but not when `driverPerSuite` is `false` | ||
Please note: When using the `driverPerTest` option, there will be no `nemo` instance in the `before`/`after` lifecycle | ||
Please note: When using the `driverPerTest` option, there will be no reliable `nemo` instance in the `before`/`after` lifecycle | ||
context. | ||
@@ -440,0 +445,0 @@ |
@@ -53,3 +53,3 @@ { | ||
"driverPerSuite": { | ||
"tests": "path:./lifecycle.js", | ||
"tests": "path:./lifecycle-suite.js", | ||
"driverPerTest": false, | ||
@@ -61,3 +61,3 @@ "mocha": { | ||
"driverPerTest": { | ||
"tests": "path:./lifecycle.js", | ||
"tests": "path:./lifecycle-per-test.js", | ||
"driverPerTest": true, | ||
@@ -64,0 +64,0 @@ "mocha": { |
@@ -26,2 +26,7 @@ module.exports = [{ | ||
} | ||
},{ | ||
type: 'root:before', | ||
listener: (context, event) => { | ||
console.log('before root event fired', event.tags.uid); | ||
} | ||
}]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
297998
56
2053
457
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbraces@3.0.2(transitive)
+ Addedchalk@3.0.0(transitive)
+ Addedchokidar@3.3.0(transitive)
+ Addedcliui@6.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@4.1.1(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedfill-range@7.0.1(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedfsevents@2.1.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedlog-symbols@3.0.0(transitive)
+ Addedmkdirp@0.5.51.0.4(transitive)
+ Addedmocha@7.2.0(transitive)
+ Addedmochawesome@5.0.0(transitive)
+ Addednode-environment-flags@1.0.6(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedreaddirp@3.2.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addeduuid@7.0.3(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedyargs@15.4.1(transitive)
+ Addedyargs-parser@18.1.3(transitive)
- Removedcommander@3.0.2(transitive)
- Removedlog-symbols@2.2.0(transitive)
- Removedmkdirp@0.5.40.5.6(transitive)
- Removedmocha@6.2.3(transitive)
- Removedmochawesome@4.1.0(transitive)
- Removednode-environment-flags@1.0.5(transitive)
- Removeduuid@3.4.0(transitive)
- Removedyargs@14.2.3(transitive)
- Removedyargs-parser@15.0.3(transitive)
Updatedcommander@^4.0.0
Updatedmkdirp@^1.0.0
Updatedmocha@^7.1.1
Updatedmochawesome@^5.0.0
Updateduuid@^7.0.0
Updatedyargs@^15.0.1