From a6d557b24c03ce41c303da8da00dde8fa74d6bb0 Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Tue, 18 Sep 2018 20:30:59 +0530 Subject: [PATCH] [Runner] fixed Gunner/Runner for newer version --- package.json | 2 +- src/runner/index.js | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index fa5a826..12de6d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@klenty/gunner", - "version": "0.10.7", + "version": "0.11.0", "description": "Zero magic, fast test-runner and assertion framework. No magic globals.", "main": "es6/index.js", "repository": { diff --git a/src/runner/index.js b/src/runner/index.js index 7d9642a..6f56cce 100644 --- a/src/runner/index.js +++ b/src/runner/index.js @@ -1,7 +1,15 @@ -const { flatten } = require('../util'); +const reporters = require('../reporters'); + +const isBrowser = + new Function("try { return this === window } catch (e) { return false }"); const runner = instances => (options = {}) => { + if(isBrowser()) + throw new Error( + 'Runner is not adapted for browsers yet.' + + ' Use regular Gunner'); + instances = Array.isArray(instances) ? instances : [ instances ]; if(!instances.length) @@ -21,11 +29,18 @@ const runner = instances => (options = {}) => { return Promise.all(RunInstances.map(instance => { return ( instance - .run(options) + .run({ reporter: 'min' }) ); })) .then(results => { - return flatten(results); + + return options.request + ? { + default: results, + [options.request]: reporters[options.request].convert(results) + } + : results; + }); };