Browse Source

[Runner] Added Gunner/Runner module

0.7.0-breaking-rewrite
Muthu Kumar 6 years ago
parent
commit
de27f4ccbb
  1. 1
      .eslintignore
  2. 1
      Runner.js
  3. 2
      package.json
  4. 39
      src/runner/index.js

1
.eslintignore

@ -0,0 +1 @@
*.min.js

1
Runner.js

@ -0,0 +1 @@
module.exports = require('./src/runner');

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "@klenty/gunner", "name": "@klenty/gunner",
"version": "0.6.0", "version": "0.6.5",
"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": {

39
src/runner/index.js

@ -0,0 +1,39 @@
const Promise = require('bluebird');
const { flatten } = require('../util');
const logger = require('../lib/logger');
const runner = instances => (options = {}) => {
instances = Array.isArray(instances) ? instances : [ instances ];
if(!instances.length)
throw new Error(`No instances were passed to Gunner Runner`);
const type = instances[0].__proto__.constructor.name;
if (type !== "Gunner" && type !== "Strategy")
throw new Error (`Runner ${type} is not one of Gunner or Strategy`);
const RunInstances = instances.filter(i =>
i.__proto__.constructor.name === type);
if (RunInstances.length !== instances.length)
throw new Error (`Not all instances were of type ${type}`);
return Promise.map(RunInstances, instance => {
return (
instance
.run()
);
})
.then(results => {
results = flatten(results);
const log = logger.create(options, true);
log(results);
return results;
});
};
module.exports = runner;
Loading…
Cancel
Save