Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
505f624dd9 | |||
ea5fbd4637 | |||
de780538a5 | |||
28b1f0bfed | |||
72b72a9ffb | |||
be393199be | |||
7b6260bb15 | |||
2345e972d5 | |||
22c44a8cd0 | |||
bae2aebf83 | |||
5fe2358bfe | |||
280ded573d | |||
6b6a92b709 | |||
c1589c2309 | |||
271d657f2c | |||
63669ea6ff |
@ -1,4 +1,4 @@
|
|||||||
# tapbundle
|
# @pushrocks/tapbundle
|
||||||
|
|
||||||
tap bundled for tapbuffer
|
tap bundled for tapbuffer
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"npmAccessLevel": "public"
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"npmts": {
|
"npmts": {
|
||||||
"testConfig": {
|
"testConfig": {
|
||||||
|
888
package-lock.json
generated
888
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 () => {
|
||||||
|
@ -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` +
|
||||||
|
@ -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
|
||||||
|
@ -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 };
|
||||||
|
Reference in New Issue
Block a user