Compare commits
34 Commits
Author | SHA1 | Date | |
---|---|---|---|
2b21566fe1 | |||
d22fc1b688 | |||
15bbf7f10c | |||
c5e068d5cd | |||
95fa33df58 | |||
42933e6bb0 | |||
5010e882f6 | |||
055d36c74e | |||
e2ac035997 | |||
ec0d6004d5 | |||
3bbca9b0b4 | |||
f16e25b413 | |||
36574d0f34 | |||
12ac28ba44 | |||
1c80c25b14 | |||
03614fe2ef | |||
8be85e1b35 | |||
baf56089d7 | |||
42cd52a2f3 | |||
140f8a2499 | |||
952b6ec2a4 | |||
c8f2a76422 | |||
e640059715 | |||
64fc6e636a | |||
753c387325 | |||
4e541b7986 | |||
b6cfc24613 | |||
61fb4ef7bb | |||
9afc1b80b5 | |||
1bb67e331b | |||
6e5a7529b0 | |||
bf2e8fd5c6 | |||
eaee03e33f | |||
a464f6d81c |
@ -1,5 +1,10 @@
|
|||||||
# gitzone standard
|
# gitzone standard
|
||||||
image: hosttoday/ht-docker-node:npmts
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .yarn/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
@ -51,10 +56,13 @@ trigger:
|
|||||||
- docker
|
- docker
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmpage
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: pages
|
stage: pages
|
||||||
script:
|
script:
|
||||||
|
- npmci command yarn global add npmpage
|
||||||
- npmci command npmpage --publish gitlab
|
- npmci command npmpage --publish gitlab
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
|
@ -18,9 +18,6 @@ tap bundled for tapbuffer
|
|||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
[](http://standardjs.com/)
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
## Usage
|
|
||||||
Use TypeScript for best in class instellisense.
|
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
5
dist/index.d.ts
vendored
5
dist/index.d.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
import 'typings-global';
|
import 'typings-global';
|
||||||
import * as tap from 'tap';
|
export { expect } from 'smartchai';
|
||||||
import { expect } from 'smartchai';
|
export { tap } from './tapbundle.classes.tap';
|
||||||
export { tap, expect };
|
|
||||||
|
8
dist/index.js
vendored
8
dist/index.js
vendored
@ -1,8 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
const tap = require("tap");
|
var smartchai_1 = require("smartchai");
|
||||||
exports.tap = tap;
|
|
||||||
const smartchai_1 = require("smartchai");
|
|
||||||
exports.expect = smartchai_1.expect;
|
exports.expect = smartchai_1.expect;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwyQkFBMEI7QUFJeEIsa0JBQUc7QUFITCx5Q0FBa0M7QUFJaEMsb0NBQU0ifQ==
|
var tapbundle_classes_tap_1 = require("./tapbundle.classes.tap");
|
||||||
|
exports.tap = tapbundle_classes_tap_1.tap;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qix1Q0FBa0M7QUFBekIsNkJBQUEsTUFBTSxDQUFBO0FBQ2YsaUVBQTZDO0FBQXBDLHNDQUFBLEdBQUcsQ0FBQSJ9
|
42
dist/tapbundle.classes.tap.d.ts
vendored
Normal file
42
dist/tapbundle.classes.tap.d.ts
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
||||||
|
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
|
||||||
|
export declare class Tap {
|
||||||
|
/**
|
||||||
|
* skip a test
|
||||||
|
*/
|
||||||
|
skip: {
|
||||||
|
test: (descriptionArg: string, functionArg: ITestFunction) => void;
|
||||||
|
};
|
||||||
|
private _tests;
|
||||||
|
/**
|
||||||
|
* 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: string, testFunction: ITestFunction): Promise<TapTest>;
|
||||||
|
/**
|
||||||
|
* wraps function
|
||||||
|
*/
|
||||||
|
wrap(functionArg: ITapWrapFunction): TapWrap;
|
||||||
|
/**
|
||||||
|
* 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: string, testFunction: ITestFunction): void;
|
||||||
|
/**
|
||||||
|
* 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: string, testFunction: ITestFunction): void;
|
||||||
|
/**
|
||||||
|
* starts the test evaluation
|
||||||
|
*/
|
||||||
|
start(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* handle errors
|
||||||
|
*/
|
||||||
|
threw(err: any): void;
|
||||||
|
}
|
||||||
|
export declare let tap: Tap;
|
100
dist/tapbundle.classes.tap.js
vendored
Normal file
100
dist/tapbundle.classes.tap.js
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
"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");
|
||||||
|
const tapbundle_classes_tapwrap_1 = require("./tapbundle.classes.tapwrap");
|
||||||
|
class Tap {
|
||||||
|
constructor() {
|
||||||
|
/**
|
||||||
|
* skip a test
|
||||||
|
*/
|
||||||
|
this.skip = {
|
||||||
|
test: (descriptionArg, functionArg) => {
|
||||||
|
console.log(`skipped test: ${descriptionArg}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this._tests = [];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
});
|
||||||
|
this._tests.push(localTest);
|
||||||
|
return localTest;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* wraps function
|
||||||
|
*/
|
||||||
|
wrap(functionArg) {
|
||||||
|
return new tapbundle_classes_tapwrap_1.TapWrap(functionArg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
this._tests.push(new tapbundle_classes_taptest_1.TapTest({
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
start() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let promiseArray = [];
|
||||||
|
// safeguard against empty test array
|
||||||
|
if (this._tests.length === 0) {
|
||||||
|
console.log('no tests specified. Ending here!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(`1..${this._tests.length}`);
|
||||||
|
for (let testKey = 0; testKey < this._tests.length; testKey++) {
|
||||||
|
let currentTest = this._tests[testKey];
|
||||||
|
let testPromise = currentTest.run(testKey);
|
||||||
|
if (currentTest.parallel) {
|
||||||
|
promiseArray.push(testPromise);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
yield testPromise;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yield Promise.all(promiseArray);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* handle errors
|
||||||
|
*/
|
||||||
|
threw(err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Tap = Tap;
|
||||||
|
exports.tap = new Tap();
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdGFwYnVuZGxlLmNsYXNzZXMudGFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFFQSwyRUFBb0U7QUFDcEUsMkVBQXVFO0FBQ3ZFO0lBQUE7UUFFRTs7V0FFRztRQUNILFNBQUksR0FBRztZQUNMLElBQUksRUFBRSxDQUFDLGNBQXNCLEVBQUUsV0FBMEI7Z0JBQ3ZELE9BQU8sQ0FBQyxHQUFHLENBQUMsaUJBQWlCLGNBQWMsRUFBRSxDQUFDLENBQUE7WUFDaEQsQ0FBQztTQUNGLENBQUE7UUFFTyxXQUFNLEdBQWMsRUFBRSxDQUFBO0lBNkVoQyxDQUFDO0lBM0VDOzs7O09BSUc7SUFDRyxJQUFJLENBQUUsZUFBdUIsRUFBRSxZQUEyQjs7WUFDOUQsSUFBSSxTQUFTLEdBQUcsSUFBSSxtQ0FBTyxDQUFDO2dCQUMxQixXQUFXLEVBQUUsZUFBZTtnQkFDNUIsWUFBWSxFQUFFLFlBQVk7Z0JBQzFCLFFBQVEsRUFBRSxLQUFLO2FBQ2hCLENBQUMsQ0FBQTtZQUNGLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO1lBQzNCLE1BQU0sQ0FBQyxTQUFTLENBQUE7UUFDbEIsQ0FBQztLQUFBO0lBRUQ7O09BRUc7SUFDSCxJQUFJLENBQUUsV0FBNkI7UUFDakMsTUFBTSxDQUFDLElBQUksbUNBQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQTtJQUNqQyxDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILFlBQVksQ0FBRSxlQUF1QixFQUFFLFlBQTJCO1FBQ2hFLElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksbUNBQU8sQ0FBQztZQUMzQixXQUFXLEVBQUUsZUFBZTtZQUM1QixZQUFZLEVBQUUsWUFBWTtZQUMxQixRQUFRLEVBQUUsSUFBSTtTQUNmLENBQUMsQ0FBQyxDQUFBO0lBQ0wsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxXQUFXLENBQUUsZUFBdUIsRUFBRSxZQUEyQjtJQUVqRSxDQUFDO0lBRUQ7O09BRUc7SUFDRyxLQUFLOztZQUNULElBQUksWUFBWSxHQUFtQixFQUFFLENBQUE7WUFFckMscUNBQXFDO1lBQ3JDLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsTUFBTSxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQzdCLE9BQU8sQ0FBQyxHQUFHLENBQUMsa0NBQWtDLENBQUMsQ0FBQTtnQkFDL0MsTUFBTSxDQUFBO1lBQ1IsQ0FBQztZQUVELE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sRUFBRSxDQUFDLENBQUE7WUFDdkMsR0FBRyxDQUFDLENBQUMsSUFBSSxPQUFPLEdBQUcsQ0FBQyxFQUFFLE9BQU8sR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sRUFBRSxPQUFPLEVBQUUsRUFBRSxDQUFDO2dCQUM5RCxJQUFJLFdBQVcsR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFFLE9BQU8sQ0FBRSxDQUFBO2dCQUN4QyxJQUFJLFdBQVcsR0FBRyxXQUFXLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFBO2dCQUMxQyxFQUFFLENBQUMsQ0FBQyxXQUFXLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQztvQkFDekIsWUFBWSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQTtnQkFDaEMsQ0FBQztnQkFBQyxJQUFJLENBQUMsQ0FBQztvQkFDTixNQUFNLFdBQVcsQ0FBQTtnQkFDbkIsQ0FBQztZQUNILENBQUM7WUFDRCxNQUFNLE9BQU8sQ0FBQyxHQUFHLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDakMsQ0FBQztLQUFBO0lBRUQ7O09BRUc7SUFDSCxLQUFLLENBQUUsR0FBRztRQUNSLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7SUFDbEIsQ0FBQztDQUNGO0FBeEZELGtCQXdGQztBQUVVLFFBQUEsR0FBRyxHQUFHLElBQUksR0FBRyxFQUFFLENBQUEifQ==
|
30
dist/tapbundle.classes.taptest.d.ts
vendored
Normal file
30
dist/tapbundle.classes.taptest.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { TapTools } from './tapbundle.classes.taptools';
|
||||||
|
import { HrtMeasurement } from 'early';
|
||||||
|
import { Deferred } from 'smartq';
|
||||||
|
export declare type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
|
||||||
|
export interface ITestFunction {
|
||||||
|
(tapTools?: TapTools): Promise<any>;
|
||||||
|
}
|
||||||
|
export declare class TapTest {
|
||||||
|
description: string;
|
||||||
|
failureAllowed: boolean;
|
||||||
|
hrtMeasurement: HrtMeasurement;
|
||||||
|
parallel: boolean;
|
||||||
|
status: TTestStatus;
|
||||||
|
tapTools: TapTools;
|
||||||
|
testFunction: ITestFunction;
|
||||||
|
testDeferred: Deferred<TapTest>;
|
||||||
|
testPromise: Promise<TapTest>;
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(optionsArg: {
|
||||||
|
description: string;
|
||||||
|
testFunction: ITestFunction;
|
||||||
|
parallel: boolean;
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* run the test
|
||||||
|
*/
|
||||||
|
run(testKeyArg: number): Promise<void>;
|
||||||
|
}
|
64
dist/tapbundle.classes.taptest.js
vendored
Normal file
64
dist/tapbundle.classes.taptest.js
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
"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 plugins = require("./tapbundle.plugins");
|
||||||
|
const tapbundle_classes_taptools_1 = require("./tapbundle.classes.taptools");
|
||||||
|
// imported interfaces
|
||||||
|
const early_1 = require("early");
|
||||||
|
class TapTest {
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor(optionsArg) {
|
||||||
|
this.testDeferred = plugins.smartq.defer();
|
||||||
|
this.testPromise = this.testDeferred.promise;
|
||||||
|
this.description = optionsArg.description;
|
||||||
|
this.hrtMeasurement = new early_1.HrtMeasurement();
|
||||||
|
this.parallel = optionsArg.parallel;
|
||||||
|
this.status = 'pending';
|
||||||
|
this.tapTools = new tapbundle_classes_taptools_1.TapTools(this);
|
||||||
|
this.testFunction = optionsArg.testFunction;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* run the test
|
||||||
|
*/
|
||||||
|
run(testKeyArg) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
this.hrtMeasurement.start();
|
||||||
|
try {
|
||||||
|
yield this.testFunction(this.tapTools);
|
||||||
|
if (this.status === 'timeout') {
|
||||||
|
throw new Error('Test succeeded, but timed out...');
|
||||||
|
}
|
||||||
|
this.hrtMeasurement.stop();
|
||||||
|
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
|
||||||
|
this.status = 'success';
|
||||||
|
this.testDeferred.resolve(this);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.hrtMeasurement.stop();
|
||||||
|
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
|
||||||
|
this.testDeferred.resolve(this);
|
||||||
|
// if the test has already succeeded before
|
||||||
|
if (this.status === 'success') {
|
||||||
|
this.status = 'errorAfterSuccess';
|
||||||
|
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull');
|
||||||
|
}
|
||||||
|
// if the test is allowed to fail
|
||||||
|
if (this.failureAllowed) {
|
||||||
|
console.log(`please note: failure allowed!`);
|
||||||
|
}
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.TapTest = TapTest;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUE4QztBQUU5Qyw2RUFBdUQ7QUFFdkQsc0JBQXNCO0FBQ3RCLGlDQUFzQztBQVd0QztJQVVFOztPQUVHO0lBQ0gsWUFBYSxVQUlaO1FBVEQsaUJBQVksR0FBc0IsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUN4RCxnQkFBVyxHQUFxQixJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQTtRQVN2RCxJQUFJLENBQUMsV0FBVyxHQUFHLFVBQVUsQ0FBQyxXQUFXLENBQUE7UUFDekMsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLHNCQUFjLEVBQUUsQ0FBQTtRQUMxQyxJQUFJLENBQUMsUUFBUSxHQUFHLFVBQVUsQ0FBQyxRQUFRLENBQUE7UUFDbkMsSUFBSSxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUE7UUFDdkIsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLHFDQUFRLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDbEMsSUFBSSxDQUFDLFlBQVksR0FBRyxVQUFVLENBQUMsWUFBWSxDQUFBO0lBQzdDLENBQUM7SUFFRDs7T0FFRztJQUNHLEdBQUcsQ0FBRSxVQUFrQjs7WUFDM0IsSUFBSSxDQUFDLGNBQWMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtZQUMzQixJQUFJLENBQUM7Z0JBQ0gsTUFBTSxJQUFJLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQTtnQkFDdEMsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLE1BQU0sS0FBSyxTQUFTLENBQUMsQ0FBQyxDQUFDO29CQUM5QixNQUFNLElBQUksS0FBSyxDQUFFLGtDQUFrQyxDQUFDLENBQUE7Z0JBQ3RELENBQUM7Z0JBQ0QsSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtnQkFDMUIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNLFVBQVUsR0FBRyxDQUFDLE1BQU0sSUFBSSxDQUFDLFdBQVcsV0FBVyxJQUFJLENBQUMsY0FBYyxDQUFDLFlBQVksSUFBSSxDQUFDLENBQUE7Z0JBQ3RHLElBQUksQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFBO2dCQUN2QixJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQTtZQUNqQyxDQUFDO1lBQUMsS0FBSyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQztnQkFDYixJQUFJLENBQUMsY0FBYyxDQUFDLElBQUksRUFBRSxDQUFBO2dCQUMxQixPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsVUFBVSxHQUFHLENBQUMsTUFBTSxJQUFJLENBQUMsV0FBVyxXQUFXLElBQUksQ0FBQyxjQUFjLENBQUMsWUFBWSxJQUFJLENBQUMsQ0FBQTtnQkFDMUcsSUFBSSxDQUFDLFlBQVksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUE7Z0JBRS9CLDJDQUEyQztnQkFDM0MsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLE1BQU0sS0FBSyxTQUFTLENBQUMsQ0FBQyxDQUFDO29CQUM5QixJQUFJLENBQUMsTUFBTSxHQUFHLG1CQUFtQixDQUFBO29CQUNqQyxPQUFPLENBQUMsR0FBRyxDQUFDLHlFQUF5RSxDQUFDLENBQUE7Z0JBQ3hGLENBQUM7Z0JBRUQsaUNBQWlDO2dCQUNqQyxFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztvQkFDeEIsT0FBTyxDQUFDLEdBQUcsQ0FBQywrQkFBK0IsQ0FBQyxDQUFBO2dCQUM5QyxDQUFDO2dCQUNELE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7WUFDbEIsQ0FBQztRQUNILENBQUM7S0FBQTtDQUNGO0FBMURELDBCQTBEQyJ9
|
16
dist/tapbundle.classes.taptools.d.ts
vendored
Normal file
16
dist/tapbundle.classes.taptools.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
export declare class TapTools {
|
||||||
|
/**
|
||||||
|
* the referenced TapTest
|
||||||
|
*/
|
||||||
|
private _tapTest;
|
||||||
|
constructor(TapTestArg: any);
|
||||||
|
/**
|
||||||
|
* allow failure
|
||||||
|
*/
|
||||||
|
allowFailure(): void;
|
||||||
|
/**
|
||||||
|
* async/await delay method
|
||||||
|
*/
|
||||||
|
delayFor(timeMilliArg: any): Promise<void>;
|
||||||
|
timeout(timeMilliArg: number): Promise<void>;
|
||||||
|
}
|
42
dist/tapbundle.classes.taptools.js
vendored
Normal file
42
dist/tapbundle.classes.taptools.js
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
"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 plugins = require("./tapbundle.plugins");
|
||||||
|
class TapTools {
|
||||||
|
constructor(TapTestArg) {
|
||||||
|
this._tapTest = TapTestArg;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* allow failure
|
||||||
|
*/
|
||||||
|
allowFailure() {
|
||||||
|
this._tapTest.failureAllowed = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* async/await delay method
|
||||||
|
*/
|
||||||
|
delayFor(timeMilliArg) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield plugins.smartdelay.delayFor(timeMilliArg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
timeout(timeMilliArg) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let timeout = new plugins.smartdelay.Timeout(timeMilliArg);
|
||||||
|
timeout.makeUnrefed();
|
||||||
|
yield timeout.promise;
|
||||||
|
if (this._tapTest.status === 'pending') {
|
||||||
|
this._tapTest.status = 'timeout';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.TapTools = TapTools;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdG9vbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUuY2xhc3Nlcy50YXB0b29scy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsK0NBQThDO0FBRzlDO0lBT0UsWUFBYSxVQUFVO1FBQ3JCLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFBO0lBQzVCLENBQUM7SUFFRDs7T0FFRztJQUNILFlBQVk7UUFDVixJQUFJLENBQUMsUUFBUSxDQUFDLGNBQWMsR0FBRyxJQUFJLENBQUE7SUFDckMsQ0FBQztJQUVEOztPQUVHO0lBQ0csUUFBUSxDQUFFLFlBQVk7O1lBQzFCLE1BQU0sT0FBTyxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDakQsQ0FBQztLQUFBO0lBRUssT0FBTyxDQUFFLFlBQW9COztZQUNqQyxJQUFJLE9BQU8sR0FBRyxJQUFJLE9BQU8sQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFBO1lBQzFELE9BQU8sQ0FBQyxXQUFXLEVBQUUsQ0FBQTtZQUNyQixNQUFNLE9BQU8sQ0FBQyxPQUFPLENBQUE7WUFDckIsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLEtBQUssU0FBUyxDQUFDLENBQUMsQ0FBQztnQkFDdkMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFBO1lBQ2xDLENBQUM7UUFDSCxDQUFDO0tBQUE7Q0FFRjtBQWxDRCw0QkFrQ0MifQ==
|
14
dist/tapbundle.classes.tapwrap.d.ts
vendored
Normal file
14
dist/tapbundle.classes.tapwrap.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export interface ITapWrapFunction {
|
||||||
|
(): Promise<any>;
|
||||||
|
}
|
||||||
|
export declare class TapWrap {
|
||||||
|
wrapFunction: ITapWrapFunction;
|
||||||
|
/**
|
||||||
|
* the constructor
|
||||||
|
*/
|
||||||
|
constructor(wrapFunctionArg: ITapWrapFunction);
|
||||||
|
/**
|
||||||
|
* run the wrapFunction
|
||||||
|
*/
|
||||||
|
run(): Promise<void>;
|
||||||
|
}
|
29
dist/tapbundle.classes.tapwrap.js
vendored
Normal file
29
dist/tapbundle.classes.tapwrap.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
"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 });
|
||||||
|
class TapWrap {
|
||||||
|
/**
|
||||||
|
* the constructor
|
||||||
|
*/
|
||||||
|
constructor(wrapFunctionArg) {
|
||||||
|
// nothing here
|
||||||
|
this.wrapFunction = wrapFunctionArg;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* run the wrapFunction
|
||||||
|
*/
|
||||||
|
run() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield this.wrapFunction();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.TapWrap = TapWrap;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwd3JhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHdyYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQU1BO0lBR0U7O09BRUc7SUFDSCxZQUFhLGVBQWlDO1FBQzVDLGVBQWU7UUFDZixJQUFJLENBQUMsWUFBWSxHQUFHLGVBQWUsQ0FBQTtJQUNyQyxDQUFDO0lBRUQ7O09BRUc7SUFDRyxHQUFHOztZQUNQLE1BQU0sSUFBSSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzNCLENBQUM7S0FBQTtDQUNGO0FBakJELDBCQWlCQyJ9
|
6
dist/tapbundle.plugins.d.ts
vendored
Normal file
6
dist/tapbundle.plugins.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import 'typings-global';
|
||||||
|
import * as early from 'early';
|
||||||
|
import * as leakage from 'leakage';
|
||||||
|
import * as smartdelay from 'smartdelay';
|
||||||
|
import * as smartq from 'smartq';
|
||||||
|
export { early, smartdelay, smartq, leakage };
|
12
dist/tapbundle.plugins.js
vendored
Normal file
12
dist/tapbundle.plugins.js
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
require("typings-global");
|
||||||
|
const early = require("early");
|
||||||
|
exports.early = early;
|
||||||
|
const leakage = require("leakage");
|
||||||
|
exports.leakage = leakage;
|
||||||
|
const smartdelay = require("smartdelay");
|
||||||
|
exports.smartdelay = smartdelay;
|
||||||
|
const smartq = require("smartq");
|
||||||
|
exports.smartq = smartq;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwrQkFBOEI7QUFNNUIsc0JBQUs7QUFMUCxtQ0FBa0M7QUFRaEMsMEJBQU87QUFQVCx5Q0FBd0M7QUFLdEMsZ0NBQVU7QUFKWixpQ0FBZ0M7QUFLOUIsd0JBQU0ifQ==
|
3
dist/tapbundle.tapcreator.d.ts
vendored
Normal file
3
dist/tapbundle.tapcreator.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export declare class TapCreator {
|
||||||
|
}
|
||||||
|
export declare let tapCreator: TapCreator;
|
7
dist/tapbundle.tapcreator.js
vendored
Normal file
7
dist/tapbundle.tapcreator.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
class TapCreator {
|
||||||
|
}
|
||||||
|
exports.TapCreator = TapCreator;
|
||||||
|
exports.tapCreator = new TapCreator();
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLnRhcGNyZWF0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUudGFwY3JlYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBO0NBRUM7QUFGRCxnQ0FFQztBQUVVLFFBQUEsVUFBVSxHQUFHLElBQUksVUFBVSxFQUFFLENBQUEifQ==
|
79
docs/index.md
Normal file
79
docs/index.md
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# tapbundle
|
||||||
|
tap bundled for tapbuffer
|
||||||
|
|
||||||
|
## Availabililty
|
||||||
|
[](https://www.npmjs.com/package/tapbundle)
|
||||||
|
[](https://GitLab.com/pushrocks/tapbundle)
|
||||||
|
[](https://github.com/pushrocks/tapbundle)
|
||||||
|
[](https://pushrocks.gitlab.io/tapbundle/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://GitLab.com/pushrocks/tapbundle/commits/master)
|
||||||
|
[](https://GitLab.com/pushrocks/tapbundle/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/tapbundle)
|
||||||
|
[](https://david-dm.org/pushrocks/tapbundle)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/tapbundle/master/dependencies/npm)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/tapbundle)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
This package includes
|
||||||
|
|
||||||
|
* tap compatible testing framework written in TypeScript
|
||||||
|
* npm package chai (through smartchai)
|
||||||
|
* npm package chai-as-promised (through smartchai)
|
||||||
|
* npm package chai-string (through smartchai)
|
||||||
|
* npm package @types/chai (through smartchai)
|
||||||
|
* npm package @types/chai-as-promised (through smartchai)
|
||||||
|
* npm package @types/chai-string (through smartchai)
|
||||||
|
|
||||||
|
It also implements its own tap testing engine, that is fully typed.
|
||||||
|
|
||||||
|
In other words: This package is fully typed :)
|
||||||
|
|
||||||
|
|
||||||
|
### Get started with writing your first test file.
|
||||||
|
```javascript
|
||||||
|
import {tap, expect} from 'tapbundle' // has typings in place
|
||||||
|
|
||||||
|
import * as myAwesomeModuleToTest from '../dist/index' // '../dist/index' is the standard path for npmts modules
|
||||||
|
|
||||||
|
tap.test('my awesome description', async (tools) => { // tools are optional parameter
|
||||||
|
tools.timeout(2000) // test will fail if it takes longer than 2000 millisenconds
|
||||||
|
})
|
||||||
|
|
||||||
|
let myTest2 = tap.test('my awesome test 2', async (tools) => {
|
||||||
|
myAwsomeModuleToTest.doSomethingAsync() // we don't wait here
|
||||||
|
await tools.delayFor(3000) // yay! :) promise based timeouts :)
|
||||||
|
console.log('This gets logged 3000 ms into the test')
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.test('my awesome test 3', async (tools) => {
|
||||||
|
expect(true).to.be.true // will not throw
|
||||||
|
await expect(tools.delayFor(2000)).to.eventually.be.fulfilled // yay expect promises :)
|
||||||
|
expect((await myTest2.promise).hrtMeasurement.milliSeconds > 1000).to.be.true // access other tests metadata :)
|
||||||
|
})
|
||||||
|
|
||||||
|
let myTest4 = tap.testParallel('my awesome test 4', async (tools) => {
|
||||||
|
await tools.delayFor(4000)
|
||||||
|
console.log('logs to console after 4 seconds into this test')
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.test('my awesome test 5', async () => {
|
||||||
|
expect(myTest4.status).to.equal('pending') // since this test will likely finish before myTest4.
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.start() // start the test, will automtically plan tests for you (so the tap parser knows when tests exit bofore they are finished)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](https://push.rocks)
|
12
npmextra.json
Normal file
12
npmextra.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"globalNpmTools": [
|
||||||
|
"npmts"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"npmts": {
|
||||||
|
"testConfig": {
|
||||||
|
"parallel": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
311
package-lock.json
generated
Normal file
311
package-lock.json
generated
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
{
|
||||||
|
"name": "tapbundle",
|
||||||
|
"version": "1.1.0",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"dependencies": {
|
||||||
|
"early": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/early/-/early-2.1.1.tgz",
|
||||||
|
"integrity": "sha1-hB4jJU6l3FTYr67ugvWrZcAO4jw=",
|
||||||
|
"dependencies": {
|
||||||
|
"beautycolor": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/beautycolor/-/beautycolor-1.0.7.tgz",
|
||||||
|
"integrity": "sha1-pHFXOKxMgiE3Hpy+tabMbRHsv3w=",
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-256-colors": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz",
|
||||||
|
"integrity": "sha1-kQ3lDvzHwJ49gvL4er1rcAwYgYo="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"leakage": {
|
||||||
|
"version": "0.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/leakage/-/leakage-0.3.0.tgz",
|
||||||
|
"integrity": "sha1-FdaYq9x2u8ZDlgH08wIOd+LVDDk=",
|
||||||
|
"dependencies": {
|
||||||
|
"es6-error": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.0.2.tgz",
|
||||||
|
"integrity": "sha1-7sXHJurO9Rt/a3PCDbbhsTsGnJg="
|
||||||
|
},
|
||||||
|
"left-pad": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.1.3.tgz",
|
||||||
|
"integrity": "sha1-YS9hwDPzqeCOk58crr7qQbbzGZo="
|
||||||
|
},
|
||||||
|
"memwatch-next": {
|
||||||
|
"version": "0.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/memwatch-next/-/memwatch-next-0.3.0.tgz",
|
||||||
|
"integrity": "sha1-IREFD5qQbgqi1ypOwPAInHhyb48=",
|
||||||
|
"dependencies": {
|
||||||
|
"bindings": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz",
|
||||||
|
"integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE="
|
||||||
|
},
|
||||||
|
"nan": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz",
|
||||||
|
"integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimist": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||||
|
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
|
||||||
|
},
|
||||||
|
"pretty-bytes": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-4.0.2.tgz",
|
||||||
|
"integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"smartchai": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/smartchai/-/smartchai-1.0.3.tgz",
|
||||||
|
"integrity": "sha1-3m0BC7i1rvJMtwsxpfUzToxBty8=",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/chai": {
|
||||||
|
"version": "3.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-3.5.2.tgz",
|
||||||
|
"integrity": "sha1-wRzSgX06QBt7oPWkIPNcVhObHB4="
|
||||||
|
},
|
||||||
|
"@types/chai-as-promised": {
|
||||||
|
"version": "0.0.29",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/chai-as-promised/-/chai-as-promised-0.0.29.tgz",
|
||||||
|
"integrity": "sha1-Q9UokqqZjhhaPePiR37bhXO+HXc=",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/promises-a-plus": {
|
||||||
|
"version": "0.0.27",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/promises-a-plus/-/promises-a-plus-0.0.27.tgz",
|
||||||
|
"integrity": "sha1-xkZRE0YUyEuPXXEUzokB02pgl4A="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/chai-string": {
|
||||||
|
"version": "1.1.30",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/chai-string/-/chai-string-1.1.30.tgz",
|
||||||
|
"integrity": "sha1-TYdEsxpaIpX8AcmB7R4tTIoHDwo="
|
||||||
|
},
|
||||||
|
"chai": {
|
||||||
|
"version": "3.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz",
|
||||||
|
"integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=",
|
||||||
|
"dependencies": {
|
||||||
|
"assertion-error": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz",
|
||||||
|
"integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw="
|
||||||
|
},
|
||||||
|
"deep-eql": {
|
||||||
|
"version": "0.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
|
||||||
|
"integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=",
|
||||||
|
"dependencies": {
|
||||||
|
"type-detect": {
|
||||||
|
"version": "0.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz",
|
||||||
|
"integrity": "sha1-C6XsKohWQORw6k6FBZcZANrFiCI="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type-detect": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-diIXzAbbJY7EiQihKY6LlRIejqI="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"chai-as-promised": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-6.0.0.tgz",
|
||||||
|
"integrity": "sha1-GgKkM6byTa+sY7nJb6FoTbGqjaY=",
|
||||||
|
"dependencies": {
|
||||||
|
"check-error": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
|
||||||
|
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"chai-string": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chai-string/-/chai-string-1.4.0.tgz",
|
||||||
|
"integrity": "sha1-NZFAwFHTak5LGl/GuRAVL0OKjUk="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"smartdelay": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/smartdelay/-/smartdelay-1.0.3.tgz",
|
||||||
|
"integrity": "sha1-X9RNrXcmLREHAvApPvqAwHLPtXk="
|
||||||
|
},
|
||||||
|
"smartq": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/smartq/-/smartq-1.1.1.tgz",
|
||||||
|
"integrity": "sha1-77NYcFJg1Brhiu9//YFfe2/hfdM=",
|
||||||
|
"dependencies": {
|
||||||
|
"typed-promisify": {
|
||||||
|
"version": "0.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/typed-promisify/-/typed-promisify-0.3.0.tgz",
|
||||||
|
"integrity": "sha1-G6CvXkRMh9gEdAbxjOSQkqEZGFM="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"typings-global": {
|
||||||
|
"version": "1.0.19",
|
||||||
|
"resolved": "https://registry.npmjs.org/typings-global/-/typings-global-1.0.19.tgz",
|
||||||
|
"integrity": "sha1-M3anLU3h5VQb9XAiSP9kw+bqMWw=",
|
||||||
|
"dependencies": {
|
||||||
|
"semver": {
|
||||||
|
"version": "5.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
|
||||||
|
"integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8="
|
||||||
|
},
|
||||||
|
"smartshell": {
|
||||||
|
"version": "1.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/smartshell/-/smartshell-1.0.8.tgz",
|
||||||
|
"integrity": "sha1-FTV1bA/oBp9+baHj+ctsj3cJTkI=",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/shelljs": {
|
||||||
|
"version": "0.7.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.7.2.tgz",
|
||||||
|
"integrity": "sha1-wr2z/oDNej2gh1DKiYrkTFiWcfM=",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": {
|
||||||
|
"version": "8.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.7.tgz",
|
||||||
|
"integrity": "sha1-+wrQS1tvbqvgNyoyqPH7ulwTDK4="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/which": {
|
||||||
|
"version": "1.0.28",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/which/-/which-1.0.28.tgz",
|
||||||
|
"integrity": "sha1-AW44dim4gXvtZT/jLqtdESecjfY="
|
||||||
|
},
|
||||||
|
"shelljs": {
|
||||||
|
"version": "0.7.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz",
|
||||||
|
"integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=",
|
||||||
|
"dependencies": {
|
||||||
|
"glob": {
|
||||||
|
"version": "7.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||||
|
"integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
|
||||||
|
"dependencies": {
|
||||||
|
"fs.realpath": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||||
|
},
|
||||||
|
"inflight": {
|
||||||
|
"version": "1.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||||
|
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||||
|
"dependencies": {
|
||||||
|
"wrappy": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
|
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"inherits": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||||
|
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||||
|
},
|
||||||
|
"minimatch": {
|
||||||
|
"version": "3.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
|
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": {
|
||||||
|
"version": "1.1.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
|
||||||
|
"integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||||
|
},
|
||||||
|
"concat-map": {
|
||||||
|
"version": "0.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
|
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"once": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
|
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||||
|
"dependencies": {
|
||||||
|
"wrappy": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
|
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"path-is-absolute": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"interpret": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.3.tgz",
|
||||||
|
"integrity": "sha1-y8NcYu7uc/Gat7EKgBURQBr8D5A="
|
||||||
|
},
|
||||||
|
"rechoir": {
|
||||||
|
"version": "0.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
|
||||||
|
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
|
||||||
|
"dependencies": {
|
||||||
|
"resolve": {
|
||||||
|
"version": "1.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz",
|
||||||
|
"integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=",
|
||||||
|
"dependencies": {
|
||||||
|
"path-parse": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz",
|
||||||
|
"integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"which": {
|
||||||
|
"version": "1.2.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz",
|
||||||
|
"integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=",
|
||||||
|
"dependencies": {
|
||||||
|
"isexe": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
package.json
11
package.json
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "tapbundle",
|
"name": "tapbundle",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"description": "tap bundled for tapbuffer",
|
"description": "tap bundled for tapbuffer",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dsit/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(npmts)"
|
||||||
},
|
},
|
||||||
@ -18,8 +18,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"early": "^2.1.1",
|
||||||
|
"leakage": "^0.3.0",
|
||||||
"smartchai": "^1.0.3",
|
"smartchai": "^1.0.3",
|
||||||
"tap": "^10.3.0",
|
"smartdelay": "^1.0.3",
|
||||||
"typings-global": "^1.0.14"
|
"smartq": "^1.1.1",
|
||||||
|
"typings-global": "^1.0.19"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
test/test.tapwrap.ts
Normal file
10
test/test.tapwrap.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { tap, expect } from '../dist/index'
|
||||||
|
|
||||||
|
let tapwrap = tap.wrap(async () => {
|
||||||
|
tap.test('should do something', async () => {
|
||||||
|
console.log('test1')
|
||||||
|
})
|
||||||
|
tap.start()
|
||||||
|
})
|
||||||
|
|
||||||
|
tapwrap.run()
|
32
test/test.ts
Normal file
32
test/test.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { tap, expect } from '../dist/index'
|
||||||
|
|
||||||
|
let test1 = tap.test('my first test -> expect true to be true', async () => {
|
||||||
|
return expect(true).to.be.true
|
||||||
|
})
|
||||||
|
|
||||||
|
let test2 = tap.test('my second test', async (tools) => {
|
||||||
|
await tools.delayFor(1000)
|
||||||
|
})
|
||||||
|
|
||||||
|
let test3 = tap.test('my third test -> test2 should take longer than test1 and endure at least 1000ms', async () => {
|
||||||
|
expect((await test1).hrtMeasurement.milliSeconds < (await test2).hrtMeasurement.milliSeconds).to.be.true
|
||||||
|
expect((await test2).hrtMeasurement.milliSeconds > 1000).to.be.true
|
||||||
|
})
|
||||||
|
|
||||||
|
let test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
|
||||||
|
tools.allowFailure()
|
||||||
|
expect(false).to.be.true
|
||||||
|
})
|
||||||
|
|
||||||
|
let test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {
|
||||||
|
tools.timeout(1000)
|
||||||
|
await tools.delayFor(500)
|
||||||
|
})
|
||||||
|
|
||||||
|
let test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async (tools) => {
|
||||||
|
tools.allowFailure()
|
||||||
|
tools.timeout(1000)
|
||||||
|
await tools.delayFor(2000)
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.start()
|
@ -1,8 +1,3 @@
|
|||||||
import 'typings-global'
|
import 'typings-global'
|
||||||
import * as tap from 'tap'
|
export { expect } from 'smartchai'
|
||||||
import { expect } from 'smartchai'
|
export { tap } from './tapbundle.classes.tap'
|
||||||
|
|
||||||
export {
|
|
||||||
tap,
|
|
||||||
expect
|
|
||||||
}
|
|
||||||
|
96
ts/tapbundle.classes.tap.ts
Normal file
96
ts/tapbundle.classes.tap.ts
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import * as plugins from './tapbundle.plugins'
|
||||||
|
|
||||||
|
import { TapTest, ITestFunction } from './tapbundle.classes.taptest'
|
||||||
|
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap'
|
||||||
|
export class Tap {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* skip a test
|
||||||
|
*/
|
||||||
|
skip = {
|
||||||
|
test: (descriptionArg: string, functionArg: ITestFunction) => {
|
||||||
|
console.log(`skipped test: ${descriptionArg}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _tests: TapTest[] = []
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
async test (testDescription: string, testFunction: ITestFunction) {
|
||||||
|
let localTest = new TapTest({
|
||||||
|
description: testDescription,
|
||||||
|
testFunction: testFunction,
|
||||||
|
parallel: false
|
||||||
|
})
|
||||||
|
this._tests.push(localTest)
|
||||||
|
return localTest
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wraps function
|
||||||
|
*/
|
||||||
|
wrap (functionArg: ITapWrapFunction) {
|
||||||
|
return new TapWrap(functionArg)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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: string, testFunction: ITestFunction) {
|
||||||
|
this._tests.push(new TapTest({
|
||||||
|
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: string, testFunction: ITestFunction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* starts the test evaluation
|
||||||
|
*/
|
||||||
|
async start () {
|
||||||
|
let promiseArray: Promise<any>[] = []
|
||||||
|
|
||||||
|
// safeguard against empty test array
|
||||||
|
if (this._tests.length === 0) {
|
||||||
|
console.log('no tests specified. Ending here!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`1..${this._tests.length}`)
|
||||||
|
for (let testKey = 0; testKey < this._tests.length; testKey++) {
|
||||||
|
let currentTest = this._tests[ testKey ]
|
||||||
|
let testPromise = currentTest.run(testKey)
|
||||||
|
if (currentTest.parallel) {
|
||||||
|
promiseArray.push(testPromise)
|
||||||
|
} else {
|
||||||
|
await testPromise
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Promise.all(promiseArray)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle errors
|
||||||
|
*/
|
||||||
|
threw (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export let tap = new Tap()
|
||||||
|
|
75
ts/tapbundle.classes.taptest.ts
Normal file
75
ts/tapbundle.classes.taptest.ts
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import * as plugins from './tapbundle.plugins'
|
||||||
|
import { tapCreator } from './tapbundle.tapcreator'
|
||||||
|
import { TapTools } from './tapbundle.classes.taptools'
|
||||||
|
|
||||||
|
// imported interfaces
|
||||||
|
import { HrtMeasurement } from 'early'
|
||||||
|
import { Deferred } from 'smartq'
|
||||||
|
|
||||||
|
// interfaces
|
||||||
|
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout'
|
||||||
|
|
||||||
|
export interface ITestFunction {
|
||||||
|
(tapTools?: TapTools): Promise<any>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class TapTest {
|
||||||
|
description: string
|
||||||
|
failureAllowed: boolean
|
||||||
|
hrtMeasurement: HrtMeasurement
|
||||||
|
parallel: boolean
|
||||||
|
status: TTestStatus
|
||||||
|
tapTools: TapTools
|
||||||
|
testFunction: ITestFunction
|
||||||
|
testDeferred: Deferred<TapTest> = plugins.smartq.defer()
|
||||||
|
testPromise: Promise<TapTest> = this.testDeferred.promise
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
constructor (optionsArg: {
|
||||||
|
description: string,
|
||||||
|
testFunction: ITestFunction,
|
||||||
|
parallel: boolean
|
||||||
|
}) {
|
||||||
|
this.description = optionsArg.description
|
||||||
|
this.hrtMeasurement = new HrtMeasurement()
|
||||||
|
this.parallel = optionsArg.parallel
|
||||||
|
this.status = 'pending'
|
||||||
|
this.tapTools = new TapTools(this)
|
||||||
|
this.testFunction = optionsArg.testFunction
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run the test
|
||||||
|
*/
|
||||||
|
async run (testKeyArg: number) {
|
||||||
|
this.hrtMeasurement.start()
|
||||||
|
try {
|
||||||
|
await this.testFunction(this.tapTools)
|
||||||
|
if (this.status === 'timeout') {
|
||||||
|
throw new Error ('Test succeeded, but timed out...')
|
||||||
|
}
|
||||||
|
this.hrtMeasurement.stop()
|
||||||
|
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`)
|
||||||
|
this.status = 'success'
|
||||||
|
this.testDeferred.resolve(this)
|
||||||
|
} catch (err) {
|
||||||
|
this.hrtMeasurement.stop()
|
||||||
|
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`)
|
||||||
|
this.testDeferred.resolve(this)
|
||||||
|
|
||||||
|
// if the test has already succeeded before
|
||||||
|
if (this.status === 'success') {
|
||||||
|
this.status = 'errorAfterSuccess'
|
||||||
|
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull')
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the test is allowed to fail
|
||||||
|
if (this.failureAllowed) {
|
||||||
|
console.log(`please note: failure allowed!`)
|
||||||
|
}
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
ts/tapbundle.classes.taptools.ts
Normal file
38
ts/tapbundle.classes.taptools.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import * as plugins from './tapbundle.plugins'
|
||||||
|
import { TapTest } from './tapbundle.classes.taptest'
|
||||||
|
|
||||||
|
export class TapTools {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the referenced TapTest
|
||||||
|
*/
|
||||||
|
private _tapTest: TapTest
|
||||||
|
|
||||||
|
constructor (TapTestArg) {
|
||||||
|
this._tapTest = TapTestArg
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* allow failure
|
||||||
|
*/
|
||||||
|
allowFailure () {
|
||||||
|
this._tapTest.failureAllowed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* async/await delay method
|
||||||
|
*/
|
||||||
|
async delayFor (timeMilliArg) {
|
||||||
|
await plugins.smartdelay.delayFor(timeMilliArg)
|
||||||
|
}
|
||||||
|
|
||||||
|
async timeout (timeMilliArg: number) {
|
||||||
|
let timeout = new plugins.smartdelay.Timeout(timeMilliArg)
|
||||||
|
timeout.makeUnrefed()
|
||||||
|
await timeout.promise
|
||||||
|
if (this._tapTest.status === 'pending') {
|
||||||
|
this._tapTest.status = 'timeout'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
24
ts/tapbundle.classes.tapwrap.ts
Normal file
24
ts/tapbundle.classes.tapwrap.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import * as plugins from './tapbundle.plugins'
|
||||||
|
|
||||||
|
export interface ITapWrapFunction {
|
||||||
|
(): Promise<any>
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TapWrap {
|
||||||
|
wrapFunction: ITapWrapFunction
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the constructor
|
||||||
|
*/
|
||||||
|
constructor (wrapFunctionArg: ITapWrapFunction) {
|
||||||
|
// nothing here
|
||||||
|
this.wrapFunction = wrapFunctionArg
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run the wrapFunction
|
||||||
|
*/
|
||||||
|
async run () {
|
||||||
|
await this.wrapFunction()
|
||||||
|
}
|
||||||
|
}
|
12
ts/tapbundle.plugins.ts
Normal file
12
ts/tapbundle.plugins.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import 'typings-global'
|
||||||
|
import * as early from 'early'
|
||||||
|
import * as leakage from 'leakage'
|
||||||
|
import * as smartdelay from 'smartdelay'
|
||||||
|
import * as smartq from 'smartq'
|
||||||
|
|
||||||
|
export {
|
||||||
|
early,
|
||||||
|
smartdelay,
|
||||||
|
smartq,
|
||||||
|
leakage
|
||||||
|
}
|
7
ts/tapbundle.tapcreator.ts
Normal file
7
ts/tapbundle.tapcreator.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import * as plugins from './tapbundle.plugins'
|
||||||
|
|
||||||
|
export class TapCreator {
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
export let tapCreator = new TapCreator()
|
Reference in New Issue
Block a user