feat(pretask): introduce new pretask functionality for setting up testing environment

This commit is contained in:
2019-11-16 23:40:36 +01:00
parent bdcc94e723
commit 427878763e
4 changed files with 45 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
import * as plugins from './tapbundle.plugins';
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask';
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
export class Tap {
@@ -25,6 +26,7 @@ export class Tap {
}
};
private _tapPreTasks: PreTask[] = [];
private _tapTests: TapTest[] = [];
private _tapTestsOnly: TapTest[] = [];
@@ -51,6 +53,10 @@ export class Tap {
return localTest;
}
public preTask (functionArg: IPreTaskFunction) {
this._tapPreTasks.push(new PreTask(functionArg));
}
/**
* wraps function
*/
@@ -82,6 +88,7 @@ export class Tap {
// safeguard against empty test array
if (this._tapTests.length === 0) {
console.log('no tests specified. Ending here!');
// TODO: throw proper error
return;
}
@@ -93,6 +100,11 @@ export class Tap {
concerningTests = this._tapTests;
}
// lets run the pretasks
for (const preTask of this._tapPreTasks) {
await preTask.run();
}
console.log(`1..${concerningTests.length}`);
for (let testKey = 0; testKey < concerningTests.length; testKey++) {
const currentTest = concerningTests[testKey];