Compare commits

..

13 Commits

Author SHA1 Message Date
36574d0f34 1.0.10 2017-04-28 11:00:28 +02:00
12ac28ba44 add skip method, wait for tapreporter is finished 2017-04-28 11:00:22 +02:00
1c80c25b14 Merge branch 'master' into 'master'
update to latest standards

See merge request !1
2017-04-28 07:49:58 +00:00
03614fe2ef update to latest standards 2017-04-28 07:49:57 +00:00
8be85e1b35 update docs 2017-04-23 22:31:16 +02:00
baf56089d7 1.0.9 2017-04-23 22:08:55 +02:00
42cd52a2f3 now has correct test time measurement 2017-04-23 22:08:52 +02:00
140f8a2499 1.0.8 2017-04-23 15:23:45 +02:00
952b6ec2a4 update docs 2017-04-23 15:23:40 +02:00
c8f2a76422 1.0.7 2017-04-23 14:35:20 +02:00
e640059715 implemet errorAfterSuccess 2017-04-23 14:35:16 +02:00
64fc6e636a 1.0.6 2017-04-23 11:10:16 +02:00
753c387325 implement tap myself 2017-04-23 11:10:13 +02:00
23 changed files with 648 additions and 1547 deletions

View File

@ -18,22 +18,6 @@ tap bundled for tapbuffer
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
note this package includes
* tap
* chai
* chai-as-promised
* @types/tap
* @types/chai
* @types/chai-as-promised
```javascript
import {tap, expect} from 'tapbundle' // has typings in place
```
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
View File

@ -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
View File

@ -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
View 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
View 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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OztPQUVHO0lBQ0gsS0FBSyxDQUFDLEdBQUc7UUFDUCxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBQ2xCLENBQUM7Q0FDRjtBQTdFRCxrQkE2RUM7QUFFVSxRQUFBLEdBQUcsR0FBRyxJQUFJLEdBQUcsRUFBRSxDQUFBIn0=

27
dist/tapbundle.classes.taptest.d.ts vendored Normal file
View File

@ -0,0 +1,27 @@
import { TapTools } from './tapbundle.classes.taptools';
import { HrtMeasurement } from 'early';
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;
/**
* constructor
*/
constructor(optionsArg: {
description: string;
testFunction: ITestFunction;
parallel: boolean;
});
/**
* run the test
*/
run(testKeyArg: number): Promise<void>;
}

57
dist/tapbundle.classes.taptest.js vendored Normal file
View File

@ -0,0 +1,57 @@
"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_taptools_1 = require("./tapbundle.classes.taptools");
// imported interfaces
const early_1 = require("early");
class TapTest {
/**
* constructor
*/
constructor(optionsArg) {
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';
}
catch (err) {
this.hrtMeasurement.stop();
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
if (this.status === 'success') {
this.status = 'errorAfterSuccess';
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull');
}
if (this.failureAllowed) {
console.log(`please note: failure allowed!`);
}
console.log(err);
}
});
}
}
exports.TapTest = TapTest;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUNBLDZFQUF1RDtBQUV2RCxzQkFBc0I7QUFDdEIsaUNBQXNDO0FBVXRDO0lBUUU7O09BRUc7SUFDSCxZQUFhLFVBSVo7UUFDQyxJQUFJLENBQUMsV0FBVyxHQUFHLFVBQVUsQ0FBQyxXQUFXLENBQUE7UUFDekMsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLHNCQUFjLEVBQUUsQ0FBQTtRQUMxQyxJQUFJLENBQUMsUUFBUSxHQUFHLFVBQVUsQ0FBQyxRQUFRLENBQUE7UUFDbkMsSUFBSSxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUE7UUFDdkIsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLHFDQUFRLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDbEMsSUFBSSxDQUF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0FBQyxNQUFNLEdBQUcsbUJBQW1CLENBQUE7b0JBQ2pDLE9BQU8sQ0FBQyxHQUFHLENBQUMseUVBQXlFLENBQUMsQ0FBQTtnQkFDeEYsQ0FBQztnQkFDRCxFQUFFLENBQUEsQ0FBQyxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztvQkFDdkIsT0FBTyxDQUFDLEdBQUcsQ0FBQywrQkFBK0IsQ0FBQyxDQUFBO2dCQUM5QyxDQUFDO2dCQUNELE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7WUFDbEIsQ0FBQztRQUNILENBQUM7S0FBQTtDQUNGO0FBbERELDBCQWtEQyJ9

16
dist/tapbundle.classes.taptools.d.ts vendored Normal file
View 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
View 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
View 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
View 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
View File

@ -0,0 +1,3 @@
export declare class TapCreator {
}
export declare let tapCreator: TapCreator;

7
dist/tapbundle.tapcreator.js vendored Normal file
View 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==

44
docs/index.md Normal file
View File

@ -0,0 +1,44 @@
# tapbundle
tap bundled for tapbuffer
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/tapbundle)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/tapbundle)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/tapbundle)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/tapbundle/)
## Status for master
[![build status](https://GitLab.com/pushrocks/tapbundle/badges/master/build.svg)](https://GitLab.com/pushrocks/tapbundle/commits/master)
[![coverage report](https://GitLab.com/pushrocks/tapbundle/badges/master/coverage.svg)](https://GitLab.com/pushrocks/tapbundle/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/tapbundle.svg)](https://www.npmjs.com/package/tapbundle)
[![Dependency Status](https://david-dm.org/pushrocks/tapbundle.svg)](https://david-dm.org/pushrocks/tapbundle)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/tapbundle/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/tapbundle/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/tapbundle/badges/code.svg)](https://www.bithound.io/github/pushrocks/tapbundle)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
This package includes
* tap compatible testing framework written in TypeScript
* npm package chai
* npm package chai-as-promised
* npm package @types/tap
* npm pacakge @types/chai
* npm package @types/chai-as-promised
In other words: This pacakge is fully typed :)
```javascript
import {tap, expect} from 'tapbundle' // has typings in place
```
For further information read the linked docs at the top of this README.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

View File

@ -1,6 +1,6 @@
{
"name": "tapbundle",
"version": "1.0.5",
"version": "1.0.10",
"description": "tap bundled for tapbuffer",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
@ -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
View 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()

View File

@ -1,8 +1,8 @@
import 'typings-global'
let tap = require('tap')
import { expect } from 'smartchai'
import { tap } from './tapbundle.classes.tap'
export {
tap,
expect
}
}

View 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()

View File

@ -0,0 +1,65 @@
import { tapCreator } from './tapbundle.tapcreator'
import { TapTools } from './tapbundle.classes.taptools'
// imported interfaces
import { HrtMeasurement } from 'early'
// 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
/**
* 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'
} catch (err) {
this.hrtMeasurement.stop()
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`)
if (this.status === 'success') {
this.status = 'errorAfterSuccess'
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull')
}
if(this.failureAllowed) {
console.log(`please note: failure allowed!`)
}
console.log(err)
}
}
}

View 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
View 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
}

View File

@ -0,0 +1,7 @@
import * as plugins from './tapbundle.plugins'
export class TapCreator {
}
export let tapCreator = new TapCreator()

1585
yarn.lock

File diff suppressed because it is too large Load Diff