Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
3bbca9b0b4 | |||
f16e25b413 | |||
36574d0f34 | |||
12ac28ba44 | |||
1c80c25b14 | |||
03614fe2ef | |||
8be85e1b35 | |||
baf56089d7 | |||
42cd52a2f3 | |||
140f8a2499 | |||
952b6ec2a4 | |||
c8f2a76422 | |||
e640059715 | |||
64fc6e636a | |||
753c387325 | |||
4e541b7986 | |||
b6cfc24613 | |||
61fb4ef7bb | |||
9afc1b80b5 | |||
1bb67e331b | |||
6e5a7529b0 | |||
bf2e8fd5c6 |
@ -1,5 +1,10 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- test
|
||||
@ -51,10 +56,13 @@ trigger:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
script:
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage --publish gitlab
|
||||
tags:
|
||||
- docker
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
|
@ -18,9 +18,6 @@ tap bundled for tapbuffer
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
|
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import 'typings-global';
|
||||
import * as tap from 'tap';
|
||||
import { expect } from 'smartchai';
|
||||
import { tap } from './tapbundle.classes.tap';
|
||||
export { tap, expect };
|
||||
|
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const tap = require("tap");
|
||||
exports.tap = tap;
|
||||
const smartchai_1 = require("smartchai");
|
||||
exports.expect = smartchai_1.expect;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwyQkFBMEI7QUFJeEIsa0JBQUc7QUFITCx5Q0FBa0M7QUFJaEMsb0NBQU0ifQ==
|
||||
const tapbundle_classes_tap_1 = require("./tapbundle.classes.tap");
|
||||
exports.tap = tapbundle_classes_tap_1.tap;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qix5Q0FBa0M7QUFLaEMsaUJBTE8sa0JBQU0sQ0FLUDtBQUpSLG1FQUE2QztBQUczQyxjQUhPLDJCQUFHLENBR1AifQ==
|
34
dist/tapbundle.classes.tap.d.ts
vendored
Normal file
34
dist/tapbundle.classes.tap.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
||||
export declare class Tap {
|
||||
skip: {
|
||||
test: (...args: any[]) => 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>;
|
||||
/**
|
||||
* 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;
|
90
dist/tapbundle.classes.tap.js
vendored
Normal file
90
dist/tapbundle.classes.tap.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"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");
|
||||
class Tap {
|
||||
constructor() {
|
||||
this.skip = {
|
||||
test: (...args) => {
|
||||
console.log('skipped');
|
||||
}
|
||||
};
|
||||
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;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdGFwYnVuZGxlLmNsYXNzZXMudGFwLnRzIl0sIm5hb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csRUFBRSxDQUFBIn0=
|
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.reject();
|
||||
// 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiL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BQUMsR0FBRyxDQUFDLCtCQUErQixDQUFDLENBQUE7Z0JBQzlDLENBQUM7Z0JBQ0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQTtZQUNsQixDQUFDO1FBQ0gsQ0FBQztLQUFBO0NBQ0Y7QUExREQsMEJBMERDIn0=
|
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>;
|
||||
}
|
40
dist/tapbundle.classes.taptools.js
vendored
Normal file
40
dist/tapbundle.classes.taptools.js
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
"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* () {
|
||||
yield plugins.smartdelay.delayFor(timeMilliArg);
|
||||
if (this._tapTest.status === 'pending') {
|
||||
this._tapTest.status = 'timeout';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.TapTools = TapTools;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdG9vbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUuY2xhc3Nlcy50YXB0b29scy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsK0NBQThDO0FBRzlDO0lBT0UsWUFBWSxVQUFVO1FBQ3BCLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFBO0lBQzVCLENBQUM7SUFFRDs7T0FFRztJQUNILFlBQVk7UUFDVixJQUFJLENBQUMsUUFBUSxDQUFDLGNBQWMsR0FBRyxJQUFJLENBQUE7SUFDckMsQ0FBQztJQUVEOztPQUVHO0lBQ0csUUFBUSxDQUFDLFlBQVk7O1lBQ3pCLE1BQU0sT0FBTyxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDakQsQ0FBQztLQUFBO0lBRUssT0FBTyxDQUFFLFlBQW9COztZQUNqQyxNQUFNLE9BQU8sQ0FBQyxVQUFVLENBQUMsUUFBUSxDQUFDLFlBQVksQ0FBQyxDQUFBO1lBQy9DLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsTUFBTSxLQUFLLFNBQVMsQ0FBQyxDQUFDLENBQUM7Z0JBQ3ZDLElBQUksQ0FBQyxRQUFRLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQTtZQUNsQyxDQUFDO1FBQ0gsQ0FBQztLQUFBO0NBRUY7QUFoQ0QsNEJBZ0NDIn0=
|
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 pacakge @types/chai (through smartchi)
|
||||
* 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.eventuall.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)
|
11
package.json
11
package.json
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "tapbundle",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.11",
|
||||
"description": "tap bundled for tapbuffer",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dsit/index.d.ts",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
},
|
||||
@ -18,8 +18,11 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
||||
"dependencies": {
|
||||
"early": "^2.1.1",
|
||||
"leakage": "^0.2.0",
|
||||
"smartchai": "^1.0.3",
|
||||
"tap": "^10.3.0",
|
||||
"typings-global": "^1.0.14"
|
||||
"smartdelay": "^1.0.1",
|
||||
"smartq": "^1.1.1",
|
||||
"typings-global": "^1.0.16"
|
||||
}
|
||||
}
|
||||
|
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,6 +1,6 @@
|
||||
import 'typings-global'
|
||||
import * as tap from 'tap'
|
||||
import { expect } from 'smartchai'
|
||||
import { tap } from './tapbundle.classes.tap'
|
||||
|
||||
export {
|
||||
tap,
|
||||
|
85
ts/tapbundle.classes.tap.ts
Normal file
85
ts/tapbundle.classes.tap.ts
Normal file
@ -0,0 +1,85 @@
|
||||
import * as plugins from './tapbundle.plugins'
|
||||
|
||||
import { TapTest, ITestFunction } from './tapbundle.classes.taptest'
|
||||
|
||||
export class Tap {
|
||||
skip = {
|
||||
test: (...args) => {
|
||||
console.log('skipped')
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.reject()
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
36
ts/tapbundle.classes.taptools.ts
Normal file
36
ts/tapbundle.classes.taptools.ts
Normal file
@ -0,0 +1,36 @@
|
||||
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) {
|
||||
await plugins.smartdelay.delayFor(timeMilliArg)
|
||||
if (this._tapTest.status === 'pending') {
|
||||
this._tapTest.status = 'timeout'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
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 {
|
||||
|
||||
}
|
||||
|
||||
export let tapCreator = new TapCreator()
|
Reference in New Issue
Block a user