Compare commits

...

16 Commits

Author SHA1 Message Date
505f624dd9 3.0.7 2018-09-03 00:01:53 +02:00
ea5fbd4637 fix(dependencies): update to latest versions 2018-09-03 00:01:53 +02:00
de780538a5 3.0.6 2018-09-02 23:54:59 +02:00
28b1f0bfed fix(core): add tap.only option 2018-09-02 23:54:59 +02:00
72b72a9ffb 3.0.5 2018-08-08 23:38:43 +02:00
be393199be fix(dependencies): update 2018-08-08 23:38:43 +02:00
7b6260bb15 3.0.4 2018-08-08 23:20:14 +02:00
2345e972d5 fix(dependencies): use @gitzone/tsbuild instead of npmts 2018-08-08 23:20:14 +02:00
22c44a8cd0 3.0.3 2018-08-08 23:17:06 +02:00
bae2aebf83 fix(dependencies): now typings-global free 2018-08-08 23:17:06 +02:00
5fe2358bfe 3.0.2 2018-07-18 08:31:22 +02:00
280ded573d fix(dependencies): update 2018-07-18 08:31:22 +02:00
6b6a92b709 3.0.1 2018-07-13 22:28:18 +02:00
c1589c2309 fix(package): npm access level 2018-07-13 22:28:17 +02:00
271d657f2c 3.0.0 2018-07-13 22:06:45 +02:00
63669ea6ff BREAKING CHANGE(package): change scope 2018-07-13 22:06:45 +02:00
8 changed files with 614 additions and 359 deletions

View File

@ -1,4 +1,4 @@
# tapbundle # @pushrocks/tapbundle
tap bundled for tapbuffer tap bundled for tapbuffer

View File

@ -1,8 +1,7 @@
{ {
"npmci": { "npmci": {
"npmGlobalTools": [ "npmGlobalTools": [],
"npmts" "npmAccessLevel": "public"
]
}, },
"npmts": { "npmts": {
"testConfig": { "testConfig": {

888
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
{ {
"name": "tapbundle", "name": "@pushrocks/tapbundle",
"private": false, "private": false,
"version": "2.0.2", "version": "3.0.7",
"description": "tap bundled for tapbuffer", "description": "tap bundled for tapbuffer",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "(tsrun test/test.ts)", "test": "(tstest test/)",
"build": "(npmts)" "build": "(tsbuild)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -20,15 +20,17 @@
}, },
"homepage": "https://gitlab.com/pushrocks/tapbundle#README", "homepage": "https://gitlab.com/pushrocks/tapbundle#README",
"dependencies": { "dependencies": {
"early": "^2.1.1", "@pushrocks/early": "^3.0.3",
"@pushrocks/smartdelay": "^2.0.2",
"@pushrocks/smartpromise": "^2.0.5",
"leakage": "^0.4.0", "leakage": "^0.4.0",
"smartchai": "^2.0.1", "smartchai": "^2.0.1"
"smartdelay": "^1.0.4",
"smartq": "^1.1.8"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsrun": "^1.0.7", "@gitzone/tsbuild": "^2.0.22",
"@types/node": "^10.5.0", "@gitzone/tsrun": "^1.1.12",
"@gitzone/tstest": "^1.0.15",
"@types/node": "^10.9.4",
"randomstring": "^1.1.5" "randomstring": "^1.1.5"
} }
} }

View File

@ -1,4 +1,4 @@
import { tap, expect } from '../dist/index'; import { tap, expect } from '../ts/index';
let tapwrap = tap.wrap(async () => { let tapwrap = tap.wrap(async () => {
tap.test('should do something', async () => { tap.test('should do something', async () => {

View File

@ -4,28 +4,46 @@ import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap'; import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
export class Tap { export class Tap {
/** /**
* skip a test * skips a test
* tests marked with tap.skip.test() are never executed
*/ */
skip = { skip = {
test: (descriptionArg: string, functionArg: ITestFunction) => { test: (descriptionArg: string, functionArg: ITestFunction) => {
console.log(`skipped test: ${descriptionArg}`); console.log(`skipped test: ${descriptionArg}`);
},
testParallel: (descriptionArg: string, functionArg: ITestFunction) => {
console.log(`skipped test: ${descriptionArg}`);
} }
}; };
/**
* only executes tests marked as ONLY
*/
only = {
test: (descriptionArg: string, testFunctionArg: ITestFunction) => {
this.test(descriptionArg, testFunctionArg, 'only');
}
}
private _tapTests: TapTest[] = []; private _tapTests: TapTest[] = [];
private _tapTestsOnly: TapTest[] = [];
/** /**
* Normal test function, will run one by one * Normal test function, will run one by one
* @param testDescription - A description of what the test does * @param testDescription - A description of what the test does
* @param testFunction - A Function that returns a Promise and resolves or rejects * @param testFunction - A Function that returns a Promise and resolves or rejects
*/ */
async test(testDescription: string, testFunction: ITestFunction) { async test(testDescription: string, testFunction: ITestFunction, modeArg: 'normal' | 'only' | 'skip' = 'normal' ) {
let localTest = new TapTest({ let localTest = new TapTest({
description: testDescription, description: testDescription,
testFunction: testFunction, testFunction: testFunction,
parallel: false parallel: false
}); });
this._tapTests.push(localTest); if(modeArg === 'normal') {
this._tapTests.push(localTest);
} else if (modeArg === 'only') {
this._tapTestsOnly.push(localTest);
}
return localTest; return localTest;
} }
@ -63,9 +81,17 @@ export class Tap {
return; return;
} }
console.log(`1..${this._tapTests.length}`); // determine which tests to run
for (let testKey = 0; testKey < this._tapTests.length; testKey++) { let concerningTests: TapTest[];
let currentTest = this._tapTests[testKey]; if(this._tapTestsOnly.length > 0) {
concerningTests = this._tapTestsOnly;
} else {
concerningTests = this._tapTests;
}
console.log(`1..${concerningTests.length}`);
for (let testKey = 0; testKey < concerningTests.length; testKey++) {
let currentTest = concerningTests[testKey];
let testPromise = currentTest.run(testKey); let testPromise = currentTest.run(testKey);
if (currentTest.parallel) { if (currentTest.parallel) {
promiseArray.push(testPromise); promiseArray.push(testPromise);
@ -79,7 +105,7 @@ export class Tap {
let failReasons: string[] = []; let failReasons: string[] = [];
let executionNotes: string[] = []; let executionNotes: string[] = [];
// collect failed tests // collect failed tests
for (let tapTest of this._tapTests) { for (let tapTest of concerningTests) {
if (tapTest.status !== 'success') { if (tapTest.status !== 'success') {
failReasons.push( failReasons.push(
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` + `Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +

View File

@ -3,8 +3,8 @@ import { tapCreator } from './tapbundle.tapcreator';
import { TapTools } from './tapbundle.classes.taptools'; import { TapTools } from './tapbundle.classes.taptools';
// imported interfaces // imported interfaces
import { HrtMeasurement } from 'early'; import { HrtMeasurement } from '@pushrocks/early';
import { Deferred } from 'smartq'; import { Deferred } from '@pushrocks/smartpromise';
// interfaces // interfaces
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout'; export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
@ -22,7 +22,7 @@ export class TapTest {
tapTools: TapTools; tapTools: TapTools;
testFunction: ITestFunction; testFunction: ITestFunction;
testKey: number; // the testKey the position in the test qeue. Set upon calling .run() testKey: number; // the testKey the position in the test qeue. Set upon calling .run()
testDeferred: Deferred<TapTest> = plugins.smartq.defer(); testDeferred: Deferred<TapTest> = plugins.smartpromise.defer();
testPromise: Promise<TapTest> = this.testDeferred.promise; testPromise: Promise<TapTest> = this.testDeferred.promise;
/** /**
* constructor * constructor

View File

@ -1,6 +1,6 @@
import * as early from 'early'; import * as early from '@pushrocks/early';
import * as leakage from 'leakage'; import * as leakage from 'leakage';
import * as smartdelay from 'smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartq from 'smartq'; import * as smartpromise from '@pushrocks/smartpromise';
export { early, smartdelay, smartq, leakage }; export { early, smartdelay, smartpromise, leakage };