tapbundle/dist/tapbundle.classes.tap.js

118 lines
7.6 KiB
JavaScript
Raw Normal View History

2017-04-28 07:49:57 +00:00
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const tapbundle_classes_taptest_1 = require("./tapbundle.classes.taptest");
2017-07-05 22:06:18 +00:00
const tapbundle_classes_tapwrap_1 = require("./tapbundle.classes.tapwrap");
2017-04-28 07:49:57 +00:00
class Tap {
constructor() {
2017-07-05 22:06:18 +00:00
/**
* skip a test
*/
this.skip = {
2017-07-05 22:06:18 +00:00
test: (descriptionArg, functionArg) => {
console.log(`skipped test: ${descriptionArg}`);
}
};
2017-07-11 13:10:05 +00:00
this._tapTests = [];
2017-04-28 07:49:57 +00:00
}
/**
* Normal test function, will run one by one
* @param testDescription - A description of what the test does
* @param testFunction - A Function that returns a Promise and resolves or rejects
*/
test(testDescription, testFunction) {
return __awaiter(this, void 0, void 0, function* () {
let localTest = new tapbundle_classes_taptest_1.TapTest({
description: testDescription,
testFunction: testFunction,
parallel: false
});
2017-07-11 13:10:05 +00:00
this._tapTests.push(localTest);
2017-04-28 07:49:57 +00:00
return localTest;
});
}
2017-07-05 22:06:18 +00:00
/**
* wraps function
*/
wrap(functionArg) {
return new tapbundle_classes_tapwrap_1.TapWrap(functionArg);
}
2017-04-28 07:49:57 +00:00
/**
* A parallel test that will not be waited for before the next starts.
* @param testDescription - A description of what the test does
* @param testFunction - A Function that returns a Promise and resolves or rejects
*/
testParallel(testDescription, testFunction) {
2017-07-11 13:10:05 +00:00
this._tapTests.push(new tapbundle_classes_taptest_1.TapTest({
2017-04-28 07:49:57 +00:00
description: testDescription,
testFunction: testFunction,
parallel: true
}));
}
/**
* tests leakage
* @param testDescription - A description of what the test does
* @param testFunction - A Function that returns a Promise and resolves or rejects
*/
testLeakage(testDescription, testFunction) {
}
/**
* starts the test evaluation
*/
2017-07-11 13:10:05 +00:00
start(optionsArg) {
2017-04-28 07:49:57 +00:00
return __awaiter(this, void 0, void 0, function* () {
let promiseArray = [];
// safeguard against empty test array
2017-07-11 13:10:05 +00:00
if (this._tapTests.length === 0) {
2017-04-28 07:49:57 +00:00
console.log('no tests specified. Ending here!');
return;
}
2017-07-11 13:10:05 +00:00
console.log(`1..${this._tapTests.length}`);
for (let testKey = 0; testKey < this._tapTests.length; testKey++) {
let currentTest = this._tapTests[testKey];
2017-04-28 07:49:57 +00:00
let testPromise = currentTest.run(testKey);
if (currentTest.parallel) {
promiseArray.push(testPromise);
}
else {
yield testPromise;
}
}
yield Promise.all(promiseArray);
2017-07-11 13:10:05 +00:00
// when tests have been run and all promises are fullfilled
let failReasons = [];
let executionNotes = [];
// collect failed tests
for (let tapTest of this._tapTests) {
if (tapTest.status !== 'success') {
failReasons.push(`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n`
+ `|| ${tapTest.description}\n`
+ `|| for more information please take a look the logs above`);
}
}
// render fail Reasons
for (let failReason of failReasons) {
console.log(failReason);
}
if (optionsArg && optionsArg.throwOnError && failReasons.length > 0) {
process.exit(1);
}
2017-04-28 07:49:57 +00:00
});
}
/**
* handle errors
*/
threw(err) {
console.log(err);
}
}
exports.Tap = Tap;
exports.tap = new Tap();
2017-10-09 19:54:46 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdGFwYnVuZGxlLmNsYXNzZXMudGFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7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