Browse Source

[testrunner] Fix for error reporting on skipped hooks

master
Muthu Kumar 6 years ago
parent
commit
bc6ed887cd
  1. 6
      browser/index.js
  2. 6
      es5/lib/testrunner.js
  3. 2
      package.json
  4. 8
      src/lib/testrunner.js

6
browser/index.js

@ -2204,6 +2204,10 @@ function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.itera
var buildTestQueue = require('./buildTestQueue'); var buildTestQueue = require('./buildTestQueue');
var getError = function getError(E) {
return E.error.stack || E.error;
};
var findSkip = function findSkip(skip, unit) { var findSkip = function findSkip(skip, unit) {
var startFailed = skip.findIndex(function (x) { var startFailed = skip.findIndex(function (x) {
return x.type === '@start'; return x.type === '@start';
@ -2214,7 +2218,7 @@ function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.itera
var beforeFailed = skip.findIndex(function (x) { var beforeFailed = skip.findIndex(function (x) {
return x.description === unit.description; return x.description === unit.description;
}); });
return startFailed !== -1 && 'A start hook failed\n' + skip[startFailed].error || everyFailed !== -1 && 'An every hook failed\n' + skip[everyFailed].error || beforeFailed !== -1 && 'A before test hook failed\n' + skip[beforeFailed].error; return startFailed !== -1 && 'A start hook failed\n' + getError(skip[startFailed]) || everyFailed !== -1 && 'An every hook failed\n' + getError(skip[everyFailed].error) || beforeFailed !== -1 && 'A before test hook failed\n' + getError(skip[beforeFailed]);
}; };
var reduceQueue = function reduceQueue(queue) { var reduceQueue = function reduceQueue(queue) {

6
es5/lib/testrunner.js

@ -32,6 +32,10 @@ var emitter = require('./emitter');
var buildTestQueue = require('./buildTestQueue'); var buildTestQueue = require('./buildTestQueue');
var getError = function getError(E) {
return E.error.stack || E.error;
};
var findSkip = function findSkip(skip, unit) { var findSkip = function findSkip(skip, unit) {
var startFailed = skip.findIndex(function (x) { var startFailed = skip.findIndex(function (x) {
return x.type === '@start'; return x.type === '@start';
@ -42,7 +46,7 @@ var findSkip = function findSkip(skip, unit) {
var beforeFailed = skip.findIndex(function (x) { var beforeFailed = skip.findIndex(function (x) {
return x.description === unit.description; return x.description === unit.description;
}); });
return startFailed !== -1 && 'A start hook failed\n' + skip[startFailed].error || everyFailed !== -1 && 'An every hook failed\n' + skip[everyFailed].error || beforeFailed !== -1 && 'A before test hook failed\n' + skip[beforeFailed].error; return startFailed !== -1 && 'A start hook failed\n' + getError(skip[startFailed]) || everyFailed !== -1 && 'An every hook failed\n' + getError(skip[everyFailed].error) || beforeFailed !== -1 && 'A before test hook failed\n' + getError(skip[beforeFailed]);
}; };
var reduceQueue = function reduceQueue(queue) { var reduceQueue = function reduceQueue(queue) {

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "@klenty/gunner", "name": "@klenty/gunner",
"version": "0.11.9", "version": "0.11.10",
"description": "Zero magic, fast test-runner and assertion framework. No magic globals.", "description": "Zero magic, fast test-runner and assertion framework. No magic globals.",
"main": "index.js", "main": "index.js",
"repository": { "repository": {

8
src/lib/testrunner.js

@ -9,6 +9,8 @@ const { eventMap } = require('../util/constants');
const emitter = require('./emitter'); const emitter = require('./emitter');
const buildTestQueue = require('./buildTestQueue'); const buildTestQueue = require('./buildTestQueue');
const getError = E => E.error.stack || E.error;
const findSkip = (skip, unit) => { const findSkip = (skip, unit) => {
const startFailed = skip.findIndex(x => const startFailed = skip.findIndex(x =>
@ -20,13 +22,13 @@ const findSkip = (skip, unit) => {
return (startFailed !== -1 return (startFailed !== -1
&& 'A start hook failed\n' && 'A start hook failed\n'
+ skip[startFailed].error) + getError(skip[startFailed]))
|| (everyFailed !== -1 || (everyFailed !== -1
&& 'An every hook failed\n' && 'An every hook failed\n'
+ skip[everyFailed].error) + getError(skip[everyFailed].error))
|| (beforeFailed !== -1 || (beforeFailed !== -1
&& 'A before test hook failed\n' && 'A before test hook failed\n'
+ skip[beforeFailed].error); + getError(skip[beforeFailed]));
}; };

Loading…
Cancel
Save