Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
588c532d6d | |||
e3a756c775 | |||
05defe6031 | |||
f4bb17dea1 | |||
1023a94ff2 | |||
8ee456da5f | |||
45ee6eca31 | |||
1eaf1e9a77 | |||
715108b11b | |||
7b1e8f47b1 | |||
2b71ffe8c2 | |||
29ec99e63e | |||
50f1aad895 | |||
f7e95df2b9 | |||
a00536996c | |||
66f49cf8aa | |||
aa3f1eb21f | |||
d81a8006b1 | |||
5fa4c1cd85 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -19,22 +19,35 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -49,9 +62,7 @@ testStable:
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@ -62,9 +73,7 @@ testBuild:
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -84,6 +93,8 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
|
15
.snyk
15
.snyk
@ -1,15 +0,0 @@
|
||||
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||
version: v1.12.0
|
||||
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
|
||||
ignore:
|
||||
'npm:shelljs:20140723':
|
||||
- smartdelay > typings-global > smartshell > shelljs:
|
||||
reason: None given
|
||||
expires: '2018-07-28T21:47:33.536Z'
|
||||
- early > typings-global > smartshell > shelljs:
|
||||
reason: None given
|
||||
expires: '2018-07-28T21:47:33.537Z'
|
||||
- early > beautycolor > typings-global > smartshell > shelljs:
|
||||
reason: None given
|
||||
expires: '2018-07-28T21:47:33.537Z'
|
||||
patch: {}
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
2
dist_ts/index.d.ts
vendored
2
dist_ts/index.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export { expect } from 'smartchai';
|
||||
export { tap } from './tapbundle.classes.tap';
|
@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var smartchai_1 = require("smartchai");
|
||||
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return smartchai_1.expect; } });
|
||||
var tapbundle_classes_tap_1 = require("./tapbundle.classes.tap");
|
||||
Object.defineProperty(exports, "tap", { enumerable: true, get: function () { return tapbundle_classes_tap_1.tap; } });
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHVDQUFtQztBQUExQixtR0FBQSxNQUFNLE9BQUE7QUFDZixpRUFBOEM7QUFBckMsNEdBQUEsR0FBRyxPQUFBIn0=
|
10
dist_ts/tapbundle.classes.pretask.d.ts
vendored
10
dist_ts/tapbundle.classes.pretask.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import { TapTools } from './tapbundle.classes.taptools';
|
||||
export interface IPreTaskFunction {
|
||||
(tapTools?: TapTools): Promise<any>;
|
||||
}
|
||||
export declare class PreTask {
|
||||
description: string;
|
||||
preTaskFunction: IPreTaskFunction;
|
||||
constructor(descriptionArg: string, preTaskFunctionArg: IPreTaskFunction);
|
||||
run(): Promise<void>;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PreTask = void 0;
|
||||
const tapbundle_classes_taptools_1 = require("./tapbundle.classes.taptools");
|
||||
class PreTask {
|
||||
constructor(descriptionArg, preTaskFunctionArg) {
|
||||
this.description = descriptionArg;
|
||||
this.preTaskFunction = preTaskFunctionArg;
|
||||
}
|
||||
async run() {
|
||||
console.log(`::__PRETASK: ${this.description}`);
|
||||
await this.preTaskFunction(new tapbundle_classes_taptools_1.TapTools(null));
|
||||
}
|
||||
}
|
||||
exports.PreTask = PreTask;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMucHJldGFzay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnByZXRhc2sudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsNkVBQXdEO0FBT3hELE1BQWEsT0FBTztJQUlsQixZQUFZLGNBQXNCLEVBQUUsa0JBQW9DO1FBQ3RFLElBQUksQ0FBQyxXQUFXLEdBQUcsY0FBYyxDQUFDO1FBQ2xDLElBQUksQ0FBQyxlQUFlLEdBQUcsa0JBQWtCLENBQUM7SUFDNUMsQ0FBQztJQUVNLEtBQUssQ0FBQyxHQUFHO1FBQ2QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDLENBQUM7UUFDaEQsTUFBTSxJQUFJLENBQUMsZUFBZSxDQUFDLElBQUkscUNBQVEsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO0lBQ2pELENBQUM7Q0FDRjtBQWJELDBCQWFDIn0=
|
50
dist_ts/tapbundle.classes.tap.d.ts
vendored
50
dist_ts/tapbundle.classes.tap.d.ts
vendored
@ -1,50 +0,0 @@
|
||||
import { IPreTaskFunction } from './tapbundle.classes.pretask';
|
||||
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
||||
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
|
||||
export declare class Tap {
|
||||
/**
|
||||
* skips a test
|
||||
* tests marked with tap.skip.test() are never executed
|
||||
*/
|
||||
skip: {
|
||||
test: (descriptionArg: string, functionArg: ITestFunction) => void;
|
||||
testParallel: (descriptionArg: string, functionArg: ITestFunction) => void;
|
||||
};
|
||||
/**
|
||||
* only executes tests marked as ONLY
|
||||
*/
|
||||
only: {
|
||||
test: (descriptionArg: string, testFunctionArg: ITestFunction) => void;
|
||||
};
|
||||
private _tapPreTasks;
|
||||
private _tapTests;
|
||||
private _tapTestsOnly;
|
||||
/**
|
||||
* 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, modeArg?: 'normal' | 'only' | 'skip'): Promise<TapTest>;
|
||||
preTask(descriptionArg: string, functionArg: IPreTaskFunction): void;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* starts the test evaluation
|
||||
*/
|
||||
start(optionsArg?: {
|
||||
throwOnError: boolean;
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* handle errors
|
||||
*/
|
||||
threw(err: any): void;
|
||||
}
|
||||
export declare let tap: Tap;
|
@ -1,160 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.tap = exports.Tap = void 0;
|
||||
const plugins = __importStar(require("./tapbundle.plugins"));
|
||||
const tapbundle_classes_pretask_1 = require("./tapbundle.classes.pretask");
|
||||
const tapbundle_classes_taptest_1 = require("./tapbundle.classes.taptest");
|
||||
const tapbundle_classes_tapwrap_1 = require("./tapbundle.classes.tapwrap");
|
||||
class Tap {
|
||||
constructor() {
|
||||
/**
|
||||
* skips a test
|
||||
* tests marked with tap.skip.test() are never executed
|
||||
*/
|
||||
this.skip = {
|
||||
test: (descriptionArg, functionArg) => {
|
||||
console.log(`skipped test: ${descriptionArg}`);
|
||||
},
|
||||
testParallel: (descriptionArg, functionArg) => {
|
||||
console.log(`skipped test: ${descriptionArg}`);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* only executes tests marked as ONLY
|
||||
*/
|
||||
this.only = {
|
||||
test: (descriptionArg, testFunctionArg) => {
|
||||
this.test(descriptionArg, testFunctionArg, 'only');
|
||||
}
|
||||
};
|
||||
this._tapPreTasks = [];
|
||||
this._tapTests = [];
|
||||
this._tapTestsOnly = [];
|
||||
}
|
||||
/**
|
||||
* 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, testFunction, modeArg = 'normal') {
|
||||
const localTest = new tapbundle_classes_taptest_1.TapTest({
|
||||
description: testDescription,
|
||||
testFunction,
|
||||
parallel: false
|
||||
});
|
||||
if (modeArg === 'normal') {
|
||||
this._tapTests.push(localTest);
|
||||
}
|
||||
else if (modeArg === 'only') {
|
||||
this._tapTestsOnly.push(localTest);
|
||||
}
|
||||
return localTest;
|
||||
}
|
||||
preTask(descriptionArg, functionArg) {
|
||||
this._tapPreTasks.push(new tapbundle_classes_pretask_1.PreTask(descriptionArg, functionArg));
|
||||
}
|
||||
/**
|
||||
* 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._tapTests.push(new tapbundle_classes_taptest_1.TapTest({
|
||||
description: testDescription,
|
||||
testFunction,
|
||||
parallel: true
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* starts the test evaluation
|
||||
*/
|
||||
async start(optionsArg) {
|
||||
// lets set the tapbundle promise
|
||||
const smartenvInstance = new plugins.smartenv.Smartenv();
|
||||
smartenvInstance.isBrowser ? globalThis.tapbundleDeferred = plugins.smartpromise.defer() : null;
|
||||
// lets continue with running the tests
|
||||
const promiseArray = [];
|
||||
// safeguard against empty test array
|
||||
if (this._tapTests.length === 0) {
|
||||
console.log('no tests specified. Ending here!');
|
||||
// TODO: throw proper error
|
||||
return;
|
||||
}
|
||||
// determine which tests to run
|
||||
let concerningTests;
|
||||
if (this._tapTestsOnly.length > 0) {
|
||||
concerningTests = this._tapTestsOnly;
|
||||
}
|
||||
else {
|
||||
concerningTests = this._tapTests;
|
||||
}
|
||||
// lets run the pretasks
|
||||
for (const preTask of this._tapPreTasks) {
|
||||
await preTask.run();
|
||||
}
|
||||
console.log(`1..${concerningTests.length}`);
|
||||
for (let testKey = 0; testKey < concerningTests.length; testKey++) {
|
||||
const currentTest = concerningTests[testKey];
|
||||
const testPromise = currentTest.run(testKey);
|
||||
if (currentTest.parallel) {
|
||||
promiseArray.push(testPromise);
|
||||
}
|
||||
else {
|
||||
await testPromise;
|
||||
}
|
||||
}
|
||||
await Promise.all(promiseArray);
|
||||
// when tests have been run and all promises are fullfilled
|
||||
const failReasons = [];
|
||||
const executionNotes = [];
|
||||
// collect failed tests
|
||||
for (const tapTest of concerningTests) {
|
||||
if (tapTest.status !== 'success') {
|
||||
failReasons.push(`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
||||
`|| ${tapTest.description}\n` +
|
||||
`|| for more information please take a look the logs above`);
|
||||
}
|
||||
}
|
||||
// render fail Reasons
|
||||
for (const failReason of failReasons) {
|
||||
console.log(failReason);
|
||||
}
|
||||
if (optionsArg && optionsArg.throwOnError && failReasons.length > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* handle errors
|
||||
*/
|
||||
threw(err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
exports.Tap = Tap;
|
||||
exports.tap = new Tap();
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZG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O0lBQ0ksS0FBSyxDQUFDLEdBQUc7UUFDZCxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0lBQ25CLENBQUM7Q0FDRjtBQXJKRCxrQkFxSkM7QUFFVSxRQUFBLEdBQUcsR0FBRyxJQUFJLEdBQUcsRUFBRSxDQUFDIn0=
|
29
dist_ts/tapbundle.classes.taptest.d.ts
vendored
29
dist_ts/tapbundle.classes.taptest.d.ts
vendored
@ -1,29 +0,0 @@
|
||||
import { TapTools } from './tapbundle.classes.taptools';
|
||||
import { Deferred } from '@pushrocks/smartpromise';
|
||||
import { HrtMeasurement } from '@pushrocks/smarttime';
|
||||
export declare type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
|
||||
export declare type ITestFunction = (tapTools?: TapTools) => Promise<any>;
|
||||
export declare class TapTest {
|
||||
description: string;
|
||||
failureAllowed: boolean;
|
||||
hrtMeasurement: HrtMeasurement;
|
||||
parallel: boolean;
|
||||
status: TTestStatus;
|
||||
tapTools: TapTools;
|
||||
testFunction: ITestFunction;
|
||||
testKey: number;
|
||||
testDeferred: Deferred<TapTest>;
|
||||
testPromise: Promise<TapTest>;
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
constructor(optionsArg: {
|
||||
description: string;
|
||||
testFunction: ITestFunction;
|
||||
parallel: boolean;
|
||||
});
|
||||
/**
|
||||
* run the test
|
||||
*/
|
||||
run(testKeyArg: number): Promise<void>;
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TapTest = void 0;
|
||||
const plugins = __importStar(require("./tapbundle.plugins"));
|
||||
const tapbundle_classes_taptools_1 = require("./tapbundle.classes.taptools");
|
||||
const smarttime_1 = require("@pushrocks/smarttime");
|
||||
class TapTest {
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
constructor(optionsArg) {
|
||||
this.testDeferred = plugins.smartpromise.defer();
|
||||
this.testPromise = this.testDeferred.promise;
|
||||
this.description = optionsArg.description;
|
||||
this.hrtMeasurement = new smarttime_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
|
||||
*/
|
||||
async run(testKeyArg) {
|
||||
this.hrtMeasurement.start();
|
||||
this.testKey = testKeyArg;
|
||||
const testNumber = testKeyArg + 1;
|
||||
try {
|
||||
await this.testFunction(this.tapTools);
|
||||
if (this.status === 'timeout') {
|
||||
throw new Error('Test succeeded, but timed out...');
|
||||
}
|
||||
this.hrtMeasurement.stop();
|
||||
console.log(`ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
|
||||
this.status = 'success';
|
||||
this.testDeferred.resolve(this);
|
||||
}
|
||||
catch (err) {
|
||||
this.hrtMeasurement.stop();
|
||||
console.log(`not ok ${testNumber} - ${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');
|
||||
}
|
||||
else {
|
||||
this.status = 'error';
|
||||
}
|
||||
// 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDZEQUErQztBQUUvQyw2RUFBd0Q7QUFJeEQsb0RBQXNEO0FBT3RELE1BQWEsT0FBTztJQVdsQjs7T0FFRztJQUNILFlBQVksVUFBbUY7UUFMeEYsaUJBQVksR0FBc0IsT0FBTyxDQUFDLFlBQVksQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUMvRCxnQkFBVyxHQUFxQixJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQztRQUsvRCxJQUFJLENBQUMsV0FBVyxHQUFHLFVBQVUsQ0FBQyxXQUFXLENBQUM7UUFDMUMsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLDBCQUFjLEVBQUUsQ0FBQztRQUMzQyxJQUFJLENBQUMsUUFBUSxHQUFHLFVBQVUsQ0FBQyxRQUFRLENBQUM7UUFDcEMsSUFBSSxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUM7UUFDeEIsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLHFDQUFRLENBQUMsSUFBSSxDQ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0FBQyxZQUFZLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO1lBRWhDLDJDQUEyQztZQUMzQyxJQUFJLElBQUksQ0FBQyxNQUFNLEtBQUssU0FBUyxFQUFFO2dCQUM3QixJQUFJLENBQUMsTUFBTSxHQUFHLG1CQUFtQixDQUFDO2dCQUNsQyxPQUFPLENBQUMsR0FBRyxDQUFDLHlFQUF5RSxDQUFDLENBQUM7YUFDeEY7aUJBQU07Z0JBQ0wsSUFBSSxDQUFDLE1BQU0sR0FBRyxPQUFPLENBQUM7YUFDdkI7WUFFRCxpQ0FBaUM7WUFDakMsSUFBSSxJQUFJLENBQUMsY0FBYyxFQUFFO2dCQUN2QixPQUFPLENBQUMsR0FBRyxDQUFDLCtCQUErQixDQUFDLENBQUM7YUFDOUM7WUFDRCxPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO1NBQ2xCO0lBQ0gsQ0FBQztDQUNGO0FBaEVELDBCQWdFQyJ9
|
24
dist_ts/tapbundle.classes.taptools.d.ts
vendored
24
dist_ts/tapbundle.classes.taptools.d.ts
vendored
@ -1,24 +0,0 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
export interface IPromiseFunc {
|
||||
(): Promise<any>;
|
||||
}
|
||||
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>;
|
||||
delayForRandom(timeMilliMinArg: any, timeMilliMaxArg: any): Promise<void>;
|
||||
timeout(timeMilliArg: number): Promise<void>;
|
||||
checkIterationLeak(iterationfuncArg: IPromiseFunc): Promise<void>;
|
||||
returnError(throwingFuncArg: IPromiseFunc): Promise<Error>;
|
||||
defer(): plugins.smartpromise.Deferred<unknown>;
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TapTools = void 0;
|
||||
const plugins = __importStar(require("./tapbundle.plugins"));
|
||||
class TapTools {
|
||||
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 delayForRandom(timeMilliMinArg, timeMilliMaxArg) {
|
||||
await plugins.smartdelay.delayForRandom(timeMilliMinArg, timeMilliMaxArg);
|
||||
}
|
||||
async timeout(timeMilliArg) {
|
||||
const timeout = new plugins.smartdelay.Timeout(timeMilliArg);
|
||||
timeout.makeUnrefed();
|
||||
await timeout.promise;
|
||||
if (this._tapTest.status === 'pending') {
|
||||
this._tapTest.status = 'timeout';
|
||||
}
|
||||
}
|
||||
async checkIterationLeak(iterationfuncArg) {
|
||||
console.log('iteration leakage checks disabled for now due to incompatibilities with node v12');
|
||||
}
|
||||
async returnError(throwingFuncArg) {
|
||||
let funcErr;
|
||||
try {
|
||||
await throwingFuncArg();
|
||||
}
|
||||
catch (err) {
|
||||
funcErr = err;
|
||||
}
|
||||
return funcErr;
|
||||
}
|
||||
defer() {
|
||||
return plugins.smartpromise.defer();
|
||||
}
|
||||
}
|
||||
exports.TapTools = TapTools;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwdG9vbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUuY2xhc3Nlcy50YXB0b29scy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsNkRBQStDO0FBTy9DLE1BQWEsUUFBUTtJQU1uQixZQUFZLFVBQVU7UUFDcEIsSUFBSSxDQUFDLFFBQVEsR0FBRyxVQUFVLENBQUM7SUFDN0IsQ0FBQztJQUVEOztPQUVHO0lBQ0ksWUFBWTtRQUNqQixJQUFJLENBQUMsUUFBUSxDQUFDLGNBQWMsR0FBRyxJQUFJLENBQUM7SUFDdEMsQ0FBQztJQUVEOztPQUVHO0lBQ0ksS0FBSyxDQUFDLFFBQVEsQ0FBQyxZQUFZO1FBQ2hDLE1BQU0sT0FBTyxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsWUFBWSxDQUFDLENBQUM7SUFDbEQsQ0FBQztJQUVNLEtBQUssQ0FBQyxjQUFjLENBQUMsZUFBZSxFQUFFLGVBQWU7UUFDMUQsTUFBTSxPQUFPLENBQUMsVUFBVSxDQUFDLGNBQWMsQ0FBQyxlQUFlLEVBQUUsZUFBZSxDQUFDLENBQUM7SUFDNUUsQ0FBQztJQUVNLEtBQUssQ0FBQyxPQUFPLENBQUMsWUFBb0I7UUFDdkMsTUFBTSxPQUFPLEdBQUcsSUFBSSxPQUFPLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQztRQUM3RCxPQUFPLENBQUMsV0FBVyxFQUFFLENBQUM7UUFDdEIsTUFBTSxPQUFPLENBQUMsT0FBTyxDQUFDO1FBQ3RCLElBQUksSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLEtBQUssU0FBUyxFQUFFO1lBQ3RDLElBQUksQ0FBQyxRQUFRLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQztTQUNsQztJQUNILENBQUM7SUFFTSxLQUFLLENBQUMsa0JBQWtCLENBQUMsZ0JBQThCO1FBQzVELE9BQU8sQ0FBQyxHQUFHLENBQUMsa0ZBQWtGLENBQUMsQ0FBQztJQUNsRyxDQUFDO0lBRU0sS0FBSyxDQUFDLFdBQVcsQ0FBQyxlQUE2QjtRQUNwRCxJQUFJLE9BQWMsQ0FBQztRQUNuQixJQUFJO1lBQ0YsTUFBTSxlQUFlLEVBQUUsQ0FBQztTQUN6QjtRQUFDLE9BQU8sR0FBRyxFQUFFO1lBQ1osT0FBTyxHQUFHLEdBQUcsQ0FBQztTQUNmO1FBQ0QsT0FBTyxPQUFPLENBQUM7SUFDakIsQ0FBQztJQUVNLEtBQUs7UUFDVixPQUFPLE9BQU8sQ0FBQyxZQUFZLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDdEMsQ0FBQztDQUNGO0FBdERELDRCQXNEQyJ9
|
14
dist_ts/tapbundle.classes.tapwrap.d.ts
vendored
14
dist_ts/tapbundle.classes.tapwrap.d.ts
vendored
@ -1,14 +0,0 @@
|
||||
export interface ITapWrapFunction {
|
||||
(): Promise<any>;
|
||||
}
|
||||
export declare class TapWrap {
|
||||
wrapFunction: ITapWrapFunction;
|
||||
/**
|
||||
* the constructor
|
||||
*/
|
||||
constructor(wrapFunctionArg: ITapWrapFunction);
|
||||
/**
|
||||
* run the wrapFunction
|
||||
*/
|
||||
run(): Promise<void>;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TapWrap = void 0;
|
||||
class TapWrap {
|
||||
/**
|
||||
* the constructor
|
||||
*/
|
||||
constructor(wrapFunctionArg) {
|
||||
// nothing here
|
||||
this.wrapFunction = wrapFunctionArg;
|
||||
}
|
||||
/**
|
||||
* run the wrapFunction
|
||||
*/
|
||||
async run() {
|
||||
// TODO: make sure it makes sense what we do here.
|
||||
await this.wrapFunction();
|
||||
}
|
||||
}
|
||||
exports.TapWrap = TapWrap;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLmNsYXNzZXMudGFwd3JhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS5jbGFzc2VzLnRhcHdyYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBTUEsTUFBYSxPQUFPO0lBR2xCOztPQUVHO0lBQ0gsWUFBWSxlQUFpQztRQUMzQyxlQUFlO1FBQ2YsSUFBSSxDQUFDLFlBQVksR0FBRyxlQUFlLENBQUM7SUFDdEMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsS0FBSyxDQUFDLEdBQUc7UUFDUCxrREFBa0Q7UUFDbEQsTUFBTSxJQUFJLENBQUMsWUFBWSxFQUFFLENBQUM7SUFDNUIsQ0FBQztDQUNGO0FBbEJELDBCQWtCQyJ9
|
4
dist_ts/tapbundle.plugins.d.ts
vendored
4
dist_ts/tapbundle.plugins.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartenv from '@pushrocks/smartenv';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
export { smartdelay, smartenv, smartpromise };
|
@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.smartpromise = exports.smartenv = exports.smartdelay = void 0;
|
||||
// pushrocks
|
||||
const smartdelay = __importStar(require("@pushrocks/smartdelay"));
|
||||
exports.smartdelay = smartdelay;
|
||||
const smartenv = __importStar(require("@pushrocks/smartenv"));
|
||||
exports.smartenv = smartenv;
|
||||
const smartpromise = __importStar(require("@pushrocks/smartpromise"));
|
||||
exports.smartpromise = smartpromise;
|
||||
// third party
|
||||
/* import * as leakage from 'leakage';
|
||||
|
||||
export { leakage }; */
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsWUFBWTtBQUNaLGtFQUFvRDtBQUkzQyxnQ0FBVTtBQUhuQiw4REFBZ0Q7QUFHM0IsNEJBQVE7QUFGN0Isc0VBQXdEO0FBRXpCLG9DQUFZO0FBRTNDLGNBQWM7QUFDZDs7c0JBRXNCIn0=
|
3
dist_ts/tapbundle.tapcreator.d.ts
vendored
3
dist_ts/tapbundle.tapcreator.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export declare class TapCreator {
|
||||
}
|
||||
export declare let tapCreator: TapCreator;
|
@ -1,8 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.tapCreator = exports.TapCreator = void 0;
|
||||
class TapCreator {
|
||||
}
|
||||
exports.TapCreator = TapCreator;
|
||||
exports.tapCreator = new TapCreator();
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLnRhcGNyZWF0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUudGFwY3JlYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxNQUFhLFVBQVU7Q0FFdEI7QUFGRCxnQ0FFQztBQUVVLFFBQUEsVUFBVSxHQUFHLElBQUksVUFBVSxFQUFFLENBQUMifQ==
|
@ -9,6 +9,7 @@
|
||||
}
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
|
4086
package-lock.json
generated
4086
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@pushrocks/tapbundle",
|
||||
"private": false,
|
||||
"version": "3.2.4",
|
||||
"version": "3.2.13",
|
||||
"description": "tap bundled for tapbuffer",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web)"
|
||||
@ -20,30 +20,35 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartdelay": "^2.0.9",
|
||||
"@pushrocks/smartenv": "^4.0.10",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@pushrocks/smarttime": "^3.0.19",
|
||||
"@open-wc/testing-helpers": "^1.8.12",
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@pushrocks/smarttime": "^3.0.38",
|
||||
"smartchai": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.24",
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsrun": "^1.2.12",
|
||||
"@gitzone/tstest": "^1.0.36",
|
||||
"@types/node": "^14.0.19",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@types/node": "^14.14.22",
|
||||
"randomstring": "^1.1.5",
|
||||
"tslint": "^6.1.2",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_web/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
@ -8,13 +8,20 @@ tap bundled for tapbuffer
|
||||
* [docs (typedoc)](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/@pushrocks/tapbundle)
|
||||
[](https://snyk.io/test/npm/@pushrocks/tapbundle)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -35,24 +42,24 @@ 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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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 => {
|
||||
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');
|
||||
});
|
@ -1,6 +1,7 @@
|
||||
import { tap, expect } from '../ts/index';
|
||||
import { tap, expect, webhelpers } from '../ts/index';
|
||||
|
||||
tap.preTask('hi there', async () => {
|
||||
const myElement = webhelpers.fixture(webhelpers.html`<div></div>`);
|
||||
console.log('this is a pretask');
|
||||
});
|
||||
|
||||
@ -8,7 +9,7 @@ const test1 = tap.test('my first test -> expect true to be true', async () => {
|
||||
return expect(true).to.be.true;
|
||||
});
|
||||
|
||||
const test2 = tap.test('my second test', async tools => {
|
||||
const test2 = tap.test('my second test', async (tools) => {
|
||||
await tools.delayFor(50);
|
||||
});
|
||||
|
||||
@ -21,17 +22,17 @@ const test3 = tap.test(
|
||||
}
|
||||
);
|
||||
|
||||
const test4 = tap.skip.test('my 4th test -> should fail', async tools => {
|
||||
const test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
|
||||
tools.allowFailure();
|
||||
expect(false).to.be.true;
|
||||
});
|
||||
|
||||
const test5 = tap.test('my 5th test -> should pass in about 500ms', async tools => {
|
||||
const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {
|
||||
tools.timeout(1000);
|
||||
await tools.delayFor(500);
|
||||
});
|
||||
|
||||
const test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async tools => {
|
||||
const test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async (tools) => {
|
||||
tools.allowFailure();
|
||||
tools.timeout(1000);
|
||||
await tools.delayFor(100);
|
||||
|
@ -1,21 +0,0 @@
|
||||
import { tap, expect } from '../ts/index';
|
||||
import * as randomstring from 'randomstring';
|
||||
|
||||
const test1 = tap.test('my first test -> expect true to be true', async tools => {
|
||||
await tools.checkIterationLeak(async () => {
|
||||
const domain = randomstring.generate(1000);
|
||||
});
|
||||
});
|
||||
|
||||
const outsideArray = [];
|
||||
|
||||
const test2 = tap.test('should throw', async tools => {
|
||||
const err = await tools.returnError(async () => {
|
||||
await tools.checkIterationLeak(async () => {
|
||||
outsideArray.push(randomstring.generate(1000));
|
||||
});
|
||||
});
|
||||
expect(err).to.be.undefined;
|
||||
});
|
||||
|
||||
tap.start();
|
@ -1,10 +1,5 @@
|
||||
import { tap, expect } from '../ts/index';
|
||||
import { tap, expect, TapWrap } from '../ts/index';
|
||||
|
||||
const tapwrap = tap.wrap(async () => {
|
||||
tap.test('should do something', async () => {
|
||||
console.log('test1');
|
||||
});
|
||||
tap.start();
|
||||
});
|
||||
tap.test('should run a test', async () => {});
|
||||
|
||||
tapwrap.run();
|
||||
tap.start();
|
||||
|
22
test/test.ts
22
test/test.ts
@ -2,36 +2,40 @@ import { tap, expect } from '../ts/index';
|
||||
|
||||
tap.preTask('hi there', async () => {
|
||||
console.log('this is a pretask');
|
||||
})
|
||||
});
|
||||
|
||||
const test1 = tap.test('my first test -> expect true to be true', async () => {
|
||||
return expect(true).to.be.true;
|
||||
});
|
||||
|
||||
const test2 = tap.test('my second test', async tools => {
|
||||
const test2 = tap.test('my second test', async (tools) => {
|
||||
await tools.delayFor(1000);
|
||||
});
|
||||
|
||||
const 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;
|
||||
expect(
|
||||
(await test1.testPromise).hrtMeasurement.milliSeconds <
|
||||
(await test2).hrtMeasurement.milliSeconds
|
||||
).to.be.true;
|
||||
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).to.be.true;
|
||||
}
|
||||
);
|
||||
|
||||
const test4 = tap.skip.test('my 4th test -> should fail', async tools => {
|
||||
const test4 = tap.test('my 4th test -> should fail', async (tools) => {
|
||||
tools.allowFailure();
|
||||
expect(false).to.be.true;
|
||||
expect(false).to.be.false;
|
||||
return 'hello';
|
||||
});
|
||||
|
||||
const test5 = tap.test('my 5th test -> should pass in about 500ms', async tools => {
|
||||
const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {
|
||||
const test4Result = await test4.testResultPromise;
|
||||
tools.timeout(1000);
|
||||
await tools.delayFor(500);
|
||||
});
|
||||
|
||||
const test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async tools => {
|
||||
const test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async (tools) => {
|
||||
tools.allowFailure();
|
||||
tools.timeout(1000);
|
||||
await tools.delayFor(2000);
|
||||
|
@ -1,2 +1,4 @@
|
||||
export { expect } from 'smartchai';
|
||||
export { tap } from './tapbundle.classes.tap';
|
||||
export { TapWrap } from './tapbundle.classes.tapwrap';
|
||||
export { webhelpers } from './webhelpers';
|
@ -1,7 +1,6 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
import { TapTools } from './tapbundle.classes.taptools';
|
||||
|
||||
|
||||
export interface IPreTaskFunction {
|
||||
(tapTools?: TapTools): Promise<any>;
|
||||
}
|
||||
@ -15,8 +14,8 @@ export class PreTask {
|
||||
this.preTaskFunction = preTaskFunctionArg;
|
||||
}
|
||||
|
||||
public async run () {
|
||||
public async run() {
|
||||
console.log(`::__PRETASK: ${this.description}`);
|
||||
await this.preTaskFunction(new TapTools(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,48 +2,47 @@ import * as plugins from './tapbundle.plugins';
|
||||
|
||||
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask';
|
||||
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
||||
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
|
||||
export class Tap {
|
||||
export class Tap <T> {
|
||||
/**
|
||||
* skips a test
|
||||
* tests marked with tap.skip.test() are never executed
|
||||
*/
|
||||
public skip = {
|
||||
test: (descriptionArg: string, functionArg: ITestFunction) => {
|
||||
test: (descriptionArg: string, functionArg: ITestFunction<T>) => {
|
||||
console.log(`skipped test: ${descriptionArg}`);
|
||||
},
|
||||
testParallel: (descriptionArg: string, functionArg: ITestFunction) => {
|
||||
testParallel: (descriptionArg: string, functionArg: ITestFunction<T>) => {
|
||||
console.log(`skipped test: ${descriptionArg}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* only executes tests marked as ONLY
|
||||
*/
|
||||
public only = {
|
||||
test: (descriptionArg: string, testFunctionArg: ITestFunction) => {
|
||||
test: (descriptionArg: string, testFunctionArg: ITestFunction<T>) => {
|
||||
this.test(descriptionArg, testFunctionArg, 'only');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
private _tapPreTasks: PreTask[] = [];
|
||||
private _tapTests: TapTest[] = [];
|
||||
private _tapTestsOnly: TapTest[] = [];
|
||||
private _tapTests: TapTest<any>[] = [];
|
||||
private _tapTestsOnly: TapTest<any>[] = [];
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public async test(
|
||||
public test(
|
||||
testDescription: string,
|
||||
testFunction: ITestFunction,
|
||||
testFunction: ITestFunction<T>,
|
||||
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
||||
) {
|
||||
const localTest = new TapTest({
|
||||
): TapTest<T> {
|
||||
const localTest = new TapTest<T>({
|
||||
description: testDescription,
|
||||
testFunction,
|
||||
parallel: false
|
||||
parallel: false,
|
||||
});
|
||||
if (modeArg === 'normal') {
|
||||
this._tapTests.push(localTest);
|
||||
@ -53,28 +52,21 @@ export class Tap {
|
||||
return localTest;
|
||||
}
|
||||
|
||||
public preTask (descriptionArg: string, functionArg: IPreTaskFunction) {
|
||||
public preTask(descriptionArg: string, functionArg: IPreTaskFunction) {
|
||||
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
|
||||
}
|
||||
|
||||
/**
|
||||
* wraps function
|
||||
*/
|
||||
public 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
|
||||
*/
|
||||
public testParallel(testDescription: string, testFunction: ITestFunction) {
|
||||
public testParallel(testDescription: string, testFunction: ITestFunction<T>) {
|
||||
this._tapTests.push(
|
||||
new TapTest({
|
||||
description: testDescription,
|
||||
testFunction,
|
||||
parallel: true
|
||||
parallel: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -85,7 +77,9 @@ export class Tap {
|
||||
public async start(optionsArg?: { throwOnError: boolean }) {
|
||||
// lets set the tapbundle promise
|
||||
const smartenvInstance = new plugins.smartenv.Smartenv();
|
||||
smartenvInstance.isBrowser ? globalThis.tapbundleDeferred = plugins.smartpromise.defer() : null;
|
||||
smartenvInstance.isBrowser
|
||||
? (globalThis.tapbundleDeferred = plugins.smartpromise.defer())
|
||||
: null;
|
||||
|
||||
// lets continue with running the tests
|
||||
const promiseArray: Array<Promise<any>> = [];
|
||||
@ -142,7 +136,10 @@ export class Tap {
|
||||
}
|
||||
|
||||
if (optionsArg && optionsArg.throwOnError && failReasons.length > 0) {
|
||||
process.exit(1);
|
||||
if (!smartenvInstance.isBrowser) process.exit(1);
|
||||
}
|
||||
if (smartenvInstance.isBrowser) {
|
||||
globalThis.tapbundleDeferred.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,23 +9,25 @@ import { HrtMeasurement } from '@pushrocks/smarttime';
|
||||
// interfaces
|
||||
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
|
||||
|
||||
export type ITestFunction = (tapTools?: TapTools) => Promise<any>;
|
||||
export interface ITestFunction <T> { (tapTools?: TapTools): Promise<T> };
|
||||
|
||||
export class TapTest {
|
||||
export class TapTest <T = unknown> {
|
||||
public description: string;
|
||||
public failureAllowed: boolean;
|
||||
public hrtMeasurement: HrtMeasurement;
|
||||
public parallel: boolean;
|
||||
public status: TTestStatus;
|
||||
public tapTools: TapTools;
|
||||
public testFunction: ITestFunction;
|
||||
public testFunction: ITestFunction<T>;
|
||||
public testKey: number; // the testKey the position in the test qeue. Set upon calling .run()
|
||||
public testDeferred: Deferred<TapTest> = plugins.smartpromise.defer();
|
||||
public testPromise: Promise<TapTest> = this.testDeferred.promise;
|
||||
private testDeferred: Deferred<TapTest<T>> = plugins.smartpromise.defer();
|
||||
public testPromise: Promise<TapTest<T>> = this.testDeferred.promise;
|
||||
private testResultDeferred: Deferred<T> = plugins.smartpromise.defer();
|
||||
public testResultPromise: Promise<T> = this.testResultDeferred.promise;
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
constructor(optionsArg: { description: string; testFunction: ITestFunction; parallel: boolean }) {
|
||||
constructor(optionsArg: { description: string; testFunction: ITestFunction<T>; parallel: boolean }) {
|
||||
this.description = optionsArg.description;
|
||||
this.hrtMeasurement = new HrtMeasurement();
|
||||
this.parallel = optionsArg.parallel;
|
||||
@ -42,8 +44,7 @@ export class TapTest {
|
||||
this.testKey = testKeyArg;
|
||||
const testNumber = testKeyArg + 1;
|
||||
try {
|
||||
|
||||
await this.testFunction(this.tapTools);
|
||||
const testReturnValue = await this.testFunction(this.tapTools);
|
||||
if (this.status === 'timeout') {
|
||||
throw new Error('Test succeeded, but timed out...');
|
||||
}
|
||||
@ -53,12 +54,14 @@ export class TapTest {
|
||||
);
|
||||
this.status = 'success';
|
||||
this.testDeferred.resolve(this);
|
||||
this.testResultDeferred.resolve(testReturnValue);
|
||||
} catch (err) {
|
||||
this.hrtMeasurement.stop();
|
||||
console.log(
|
||||
`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`
|
||||
);
|
||||
this.testDeferred.resolve(this);
|
||||
this.testResultDeferred.resolve(err);
|
||||
|
||||
// if the test has already succeeded before
|
||||
if (this.status === 'success') {
|
||||
|
@ -42,10 +42,6 @@ export class TapTools {
|
||||
}
|
||||
}
|
||||
|
||||
public async checkIterationLeak(iterationfuncArg: IPromiseFunc) {
|
||||
console.log('iteration leakage checks disabled for now due to incompatibilities with node v12');
|
||||
}
|
||||
|
||||
public async returnError(throwingFuncArg: IPromiseFunc) {
|
||||
let funcErr: Error;
|
||||
try {
|
||||
|
@ -1,25 +1,13 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
|
||||
export interface ITapWrapFunction {
|
||||
(): Promise<any>;
|
||||
export interface ITapWrapOptions {
|
||||
before: () => Promise<any>;
|
||||
after: () => {};
|
||||
}
|
||||
|
||||
export class TapWrap {
|
||||
wrapFunction: ITapWrapFunction;
|
||||
|
||||
/**
|
||||
* the constructor
|
||||
*/
|
||||
constructor(wrapFunctionArg: ITapWrapFunction) {
|
||||
// nothing here
|
||||
this.wrapFunction = wrapFunctionArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* run the wrapFunction
|
||||
*/
|
||||
async run() {
|
||||
// TODO: make sure it makes sense what we do here.
|
||||
await this.wrapFunction();
|
||||
public options: ITapWrapOptions;
|
||||
constructor(optionsArg: ITapWrapOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
}
|
||||
|
25
ts/webhelpers.ts
Normal file
25
ts/webhelpers.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
import type { fixture, html } from '@open-wc/testing-helpers';
|
||||
import { tap } from './tapbundle.classes.tap';
|
||||
|
||||
class WebHelpers {
|
||||
html: typeof html;
|
||||
fixture: typeof fixture;
|
||||
|
||||
constructor() {
|
||||
const smartenv = new plugins.smartenv.Smartenv();
|
||||
if(smartenv.isBrowser) {
|
||||
this.enable();
|
||||
}
|
||||
}
|
||||
|
||||
public enable() {
|
||||
tap.preTask('enable webhelpers', async () => {
|
||||
const webhelpers = await import('@open-wc/testing-helpers')
|
||||
this.html = webhelpers.html;
|
||||
this.fixture = webhelpers.fixture;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const webhelpers = new WebHelpers();
|
Reference in New Issue
Block a user