From d29f549fc60b80f207106d67b5d0fed222b1327c Mon Sep 17 00:00:00 2001 From: Anton Usmansky Date: Sat, 27 Jan 2018 16:47:03 +0300 Subject: [PATCH] fix: afterEach hook error overwrites original test error --- .../runner/mocha-runner/mocha-adapter.js | 2 +- package-lock.json | 283 ++++++++++++++---- .../runner/mocha-runner/mocha-adapter.js | 35 +++ 3 files changed, 264 insertions(+), 56 deletions(-) diff --git a/lib/worker/runner/mocha-runner/mocha-adapter.js b/lib/worker/runner/mocha-runner/mocha-adapter.js index da9aba797..7669b9fe5 100644 --- a/lib/worker/runner/mocha-runner/mocha-adapter.js +++ b/lib/worker/runner/mocha-runner/mocha-adapter.js @@ -208,7 +208,7 @@ module.exports = class MochaAdapter extends EventEmitter { const defer = q.defer(); - this.on(RunnerEvents.ERROR, (err) => this._fail = err); + this.on(RunnerEvents.ERROR, (err) => this._fail = this._fail || err); this.on(RunnerEvents.TEST_FAIL, (data) => this._fail = data.err); this._errMonitor.on('err', (err) => defer.reject(err)); diff --git a/package-lock.json b/package-lock.json index 4a285540f..cffb44c0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,19 @@ { "name": "hermione", - "version": "0.55.0", + "version": "0.56.0", "lockfileVersion": 1, "requires": true, "dependencies": { + "JSONStream": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", + "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", @@ -432,7 +442,7 @@ "deep-eql": "3.0.1", "get-func-name": "2.0.0", "pathval": "1.1.0", - "type-detect": "4.0.5" + "type-detect": "4.0.7" } }, "chai-as-promised": { @@ -563,6 +573,27 @@ "integrity": "sha1-S5BvZw5aljqHt2sOFolkM0G2Ajw=", "dev": true }, + "collections": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/collections/-/collections-2.0.3.tgz", + "integrity": "sha1-dlcSXoSkCGotx5f/LWltgZpyD7U=", + "requires": { + "mini-map": "1.0.0", + "pop-arrayify": "1.0.0", + "pop-clear": "1.0.0", + "pop-clone": "1.0.1", + "pop-compare": "1.0.0", + "pop-equals": "1.0.0", + "pop-has": "1.0.0", + "pop-hash": "1.0.1", + "pop-iterate": "1.0.1", + "pop-observe": "2.0.2", + "pop-swap": "1.0.0", + "pop-zip": "1.0.0", + "regexp-escape": "0.0.1", + "weak-map": "1.0.5" + } + }, "color-convert": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-0.5.3.tgz", @@ -743,8 +774,8 @@ "integrity": "sha512-8MD05yN0Zb6aRsZnFX1ET+8rHWfWJk+my7ANCJZBU2mhz7TSB1fk2vZhkrwVy/PCllcTYAP/1T1NiWQ7Z01mKw==", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.2", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.2.0", @@ -936,7 +967,7 @@ "json-stringify-safe": "5.0.1", "lodash": "4.17.4", "meow": "3.7.0", - "semver": "5.4.1", + "semver": "5.5.0", "split": "1.0.1", "through2": "2.0.3" } @@ -957,8 +988,8 @@ "integrity": "sha1-4ye1MZThp61dxjR57pCZpSsCSGU=", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.2", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.2.0", @@ -1062,7 +1093,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "dargs": { @@ -1120,7 +1151,7 @@ "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", "dev": true, "requires": { - "type-detect": "4.0.5" + "type-detect": "4.0.7" } }, "deep-extend": { @@ -1300,9 +1331,9 @@ } }, "es5-ext": { - "version": "0.10.37", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.37.tgz", - "integrity": "sha1-DudB0Ui4AGm6J9AgOTdWryV978M=", + "version": "0.10.38", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.38.tgz", + "integrity": "sha512-jCMyePo7AXbUESwbl8Qi01VSH2piY9s/a3rSU/5w/MlTIx8HPL1xn2InGN8ejt/xulcJgnTO7vqNtOAxzYd2Kg==", "dev": true, "requires": { "es6-iterator": "2.0.3", @@ -1316,7 +1347,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-symbol": "3.1.1" } }, @@ -1327,7 +1358,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-set": "0.1.5", "es6-symbol": "3.1.1", @@ -1347,7 +1378,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" @@ -1360,7 +1391,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "es6-weak-map": { @@ -1370,7 +1401,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1" } @@ -1452,7 +1483,7 @@ "imurmurhash": "0.1.4", "inquirer": "0.12.0", "is-my-json-valid": "2.17.1", - "is-resolvable": "1.0.1", + "is-resolvable": "1.1.0", "js-yaml": "3.10.0", "json-stable-stringify": "1.0.1", "levn": "0.3.0", @@ -1637,7 +1668,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "exit-hook": { @@ -1864,18 +1895,37 @@ } }, "gemini-core": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/gemini-core/-/gemini-core-2.3.1.tgz", - "integrity": "sha512-yzmd4u73sx/37qc0yzWKTi6nYXlHwAM+6U8h+47LtpO5k4w9+IbDkOBLK4EdGmOCcgiQ0aCLioTGUflaS28bSg==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/gemini-core/-/gemini-core-2.3.2.tgz", + "integrity": "sha512-9Xi26w6xTmzXDcK8AW/Fj0k1NQFj/mThrUnqsyp8FpFxZiPRdKT6O69ikrQmBqt2b1RXYYqw5fL0aPItnNDZOQ==", "requires": { "bluebird": "3.5.1", "debug": "2.6.9", "gemini-configparser": "1.0.0", + "glob-extra": "2.0.0", "lodash": "4.17.4", "looks-same": "3.3.0", "micromatch": "2.3.11", "png-img": "2.1.1", "temp": "0.8.3" + }, + "dependencies": { + "glob-extra": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/glob-extra/-/glob-extra-2.0.0.tgz", + "integrity": "sha1-HzHK8n5ZsQUwiYvx1+9KZ3l6Ovw=", + "requires": { + "glob": "7.1.2", + "lodash": "4.17.4", + "q": "1.5.1", + "q-io": "2.0.6" + } + }, + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" + } } }, "generate-function": { @@ -1972,7 +2022,7 @@ "dev": true, "requires": { "meow": "3.7.0", - "semver": "5.4.1" + "semver": "5.5.0" } }, "git-toplevel": { @@ -2522,9 +2572,9 @@ "dev": true }, "is-resolvable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.1.tgz", - "integrity": "sha512-y5CXYbzvB3jTnWAZH1Nl7ykUWb6T3BcTs56HUruwBf8MhF56n1HWqhDWnVFo8GHrUPDgvUUNVhrc2U8W7iqz5g==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-subset": { @@ -2744,16 +2794,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "JSONStream": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", - "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -2979,6 +3019,11 @@ "regex-cache": "0.4.4" } }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, "mime-db": { "version": "1.30.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", @@ -2992,11 +3037,21 @@ "mime-db": "1.30.0" } }, + "mimeparse": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/mimeparse/-/mimeparse-0.1.4.tgz", + "integrity": "sha1-2vsCdSNw/SJgk64xUsJxrwGsJUo=" + }, "mimic-fn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=" }, + "mini-map": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mini-map/-/mini-map-1.0.0.tgz", + "integrity": "sha1-lkHgEV2Zs9wTcRz4z9pMgZmJP04=" + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -3156,7 +3211,7 @@ "requires": { "hosted-git-info": "2.5.0", "is-builtin-module": "1.0.0", - "semver": "5.4.1", + "semver": "5.5.0", "validate-npm-package-license": "3.0.1" } }, @@ -3441,11 +3496,79 @@ "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.3.1.tgz", "integrity": "sha512-ggXCTsqHRIsGMkHlCEhbHhUmNTA2r1lpkE0NL4Q9S8spkXbm4vE9TVmPso2AGYn90Gltdz8W5CyzhcIGg2Gejg==" }, + "pop-arrayify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pop-arrayify/-/pop-arrayify-1.0.0.tgz", + "integrity": "sha1-ZVIrP+OuIb5PjosrnkRjTBWmxIE=" + }, + "pop-clear": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pop-clear/-/pop-clear-1.0.0.tgz", + "integrity": "sha1-/IFk/IX4nyiPI7k2toAeqCKuRYY=" + }, + "pop-clone": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pop-clone/-/pop-clone-1.0.1.tgz", + "integrity": "sha1-YY1GJJfpbQb5zaMVsyXMo6JjYDg=", + "requires": { + "mini-map": "1.0.0", + "pop-equals": "1.0.0" + } + }, + "pop-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pop-compare/-/pop-compare-1.0.0.tgz", + "integrity": "sha1-xzLiLCfwz6uAohfUXncitc4VGCA=" + }, + "pop-equals": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pop-equals/-/pop-equals-1.0.0.tgz", + "integrity": "sha1-kEFPj9pxo3+IHR5eOi4C7ww7fgs=", + "requires": { + "mini-map": "1.0.0" + } + }, + "pop-has": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pop-has/-/pop-has-1.0.0.tgz", + "integrity": "sha1-myJrWblgq2XqsLQS3VVw3OkOZRw=", + "requires": { + "pop-equals": "1.0.0" + } + }, + "pop-hash": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pop-hash/-/pop-hash-1.0.1.tgz", + "integrity": "sha1-vNaUVL0vmd7SC1/Iork9a1+rRMw=", + "requires": { + "weak-map": "1.0.5" + } + }, "pop-iterate": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/pop-iterate/-/pop-iterate-1.0.1.tgz", "integrity": "sha1-zqz9q0q/NT16DyqqLB/Hs/lBO6M=" }, + "pop-observe": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/pop-observe/-/pop-observe-2.0.2.tgz", + "integrity": "sha1-WstaxvJMfG/6ssMhUbCtt0Du82M=", + "requires": { + "pop-equals": "1.0.0", + "pop-has": "1.0.0", + "pop-swap": "1.0.0" + } + }, + "pop-swap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pop-swap/-/pop-swap-1.0.0.tgz", + "integrity": "sha1-iLRAVT4IXQF50yJVsJ+TqrmJDGY=" + }, + "pop-zip": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pop-zip/-/pop-zip-1.0.0.tgz", + "integrity": "sha1-PcEUAHss7OdP87jOpz6xIMcNsFY=" + }, "pos": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/pos/-/pos-0.4.2.tgz", @@ -3498,6 +3621,11 @@ "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=" }, + "punycode": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.0.0.tgz", + "integrity": "sha1-zp5sbpwdtYJxdPzrEv9JOHAKG9M=" + }, "q": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/q/-/q-2.0.3.tgz", @@ -3508,6 +3636,19 @@ "weak-map": "1.0.5" } }, + "q-io": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/q-io/-/q-io-2.0.6.tgz", + "integrity": "sha1-8ceCdu3F0xMVOr+sXOyGqgbINwk=", + "requires": { + "collections": "2.0.3", + "mime": "1.6.0", + "mimeparse": "0.1.4", + "q": "2.0.3", + "qs": "0.6.6", + "url2": "2.0.0" + } + }, "q-promise-utils": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/q-promise-utils/-/q-promise-utils-1.1.0.tgz", @@ -3529,6 +3670,16 @@ } } }, + "qs": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/qs/-/qs-0.6.6.tgz", + "integrity": "sha1-bgFQmP9RlouKPIGQAdXyyJvEsQc=" + }, + "querystring": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.1.0.tgz", + "integrity": "sha1-y3aibNoKEKlBY/zbPhMoJ/BLexA=" + }, "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", @@ -3681,6 +3832,11 @@ "is-equal-shallow": "0.1.3" } }, + "regexp-escape": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/regexp-escape/-/regexp-escape-0.0.1.tgz", + "integrity": "sha1-PzJqBi2PdZaykUkpVQqsd+r43nU=" + }, "remark": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/remark/-/remark-5.1.0.tgz", @@ -3775,7 +3931,7 @@ "stringstream": "0.0.5", "tough-cookie": "2.3.3", "tunnel-agent": "0.6.0", - "uuid": "3.1.0" + "uuid": "3.2.1" }, "dependencies": { "qs": { @@ -3888,9 +4044,9 @@ "dev": true }, "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -3933,7 +4089,7 @@ "path-to-regexp": "1.7.0", "samsam": "1.3.0", "text-encoding": "0.6.4", - "type-detect": "4.0.5" + "type-detect": "4.0.7" }, "dependencies": { "diff": { @@ -4060,7 +4216,7 @@ "figures": "1.7.0", "fs-access": "1.0.1", "object-assign": "4.1.1", - "semver": "5.4.1", + "semver": "5.5.0", "yargs": "6.6.0" }, "dependencies": { @@ -4134,14 +4290,6 @@ } } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -4166,6 +4314,14 @@ } } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringify-entities": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.3.1.tgz", @@ -4431,9 +4587,9 @@ } }, "type-detect": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.5.tgz", - "integrity": "sha512-N9IvkQslUGYGC24RkJk1ba99foK6TkwC2FHAEBlQFBP0RxQZS8ZpJuAZcwiY/w9ZJHFQb1aOXBI60OdxhTrwEQ==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.7.tgz", + "integrity": "sha512-4Rh17pAMVdMWzktddFhISRnUnFIStObtUMNGzDwlA6w/77bmGv3aBbRdCmQR6IjzfkTo9otnW+2K/cDRhKSxDA==", "dev": true }, "typedarray": { @@ -4539,6 +4695,23 @@ "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=" }, + "url": { + "version": "0.7.9", + "resolved": "https://registry.npmjs.org/url/-/url-0.7.9.tgz", + "integrity": "sha1-GVmxqLNh/AF7WVE6fH+pgn9eTtA=", + "requires": { + "punycode": "1.0.0", + "querystring": "0.1.0" + } + }, + "url2": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/url2/-/url2-2.0.0.tgz", + "integrity": "sha1-kKOjZ945y0avQWAqAWnuho30USw=", + "requires": { + "url": "0.7.9" + } + }, "user-home": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", @@ -4554,9 +4727,9 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" }, "validate-npm-package-license": { "version": "3.0.1", diff --git a/test/lib/worker/runner/mocha-runner/mocha-adapter.js b/test/lib/worker/runner/mocha-runner/mocha-adapter.js index 47cd1ccca..19aecaf9f 100644 --- a/test/lib/worker/runner/mocha-runner/mocha-adapter.js +++ b/test/lib/worker/runner/mocha-runner/mocha-adapter.js @@ -4,6 +4,7 @@ const _ = require('lodash'); const q = require('q'); const proxyquire = require('proxyquire'); const BrowserAgent = require('gemini-core').BrowserAgent; +const RunnerEvents = require('lib/constants/runner-events'); const MochaStub = require('../../../_mocha'); describe('worker/mocha-adapter', () => { @@ -42,4 +43,38 @@ describe('worker/mocha-adapter', () => { .then((data) => assert.property(data, 'hermioneCtx')); }); }); + + describe('runInSession', () => { + it('should return test error on test fail', () => { + const mochaAdapter = mkMochaAdapter_(); + MochaStub.lastInstance.updateSuiteTree((suite) => { + return suite + .addTest({fn: () => mochaAdapter.emit(RunnerEvents.TEST_FAIL, {err: new Error('test fail')})}); + }); + + return assert.isRejected(mochaAdapter.runInSession(), /test fail/); + }); + + it('should return hook error on afterEach hook fail', () => { + const mochaAdapter = mkMochaAdapter_(); + MochaStub.lastInstance.updateSuiteTree((suite) => { + return suite + .addTest() + .afterEach(() => mochaAdapter.emit(RunnerEvents.ERROR, new Error('hook fail'))); + }); + + return assert.isRejected(mochaAdapter.runInSession(), /hook fail/); + }); + + it('should return test error if both test and afterEach hook failed', () => { + const mochaAdapter = mkMochaAdapter_(); + MochaStub.lastInstance.updateSuiteTree((suite) => { + return suite + .addTest({fn: () => mochaAdapter.emit(RunnerEvents.TEST_FAIL, {err: new Error('test fail')})}) + .afterEach(() => mochaAdapter.emit(RunnerEvents.ERROR, new Error('hook fail'))); + }); + + return assert.isRejected(mochaAdapter.runInSession(), /test fail/); + }); + }); });