Compare commits

...

11 Commits

Author SHA1 Message Date
a00536996c 3.2.6 2020-07-08 00:17:32 +00:00
66f49cf8aa fix(core): update 2020-07-08 00:17:31 +00:00
aa3f1eb21f update readme 2020-07-08 00:17:25 +00:00
d81a8006b1 3.2.5 2020-07-08 00:16:10 +00:00
5fa4c1cd85 fix(core): update 2020-07-08 00:16:09 +00:00
fc609858ff 3.2.4 2020-07-08 00:15:45 +00:00
19ecca0179 fix(core): update 2020-07-08 00:15:44 +00:00
ff55e596cb 3.2.3 2020-07-08 00:11:16 +00:00
ed8c8312c2 fix(core): update 2020-07-08 00:11:16 +00:00
a6dd8de0db 3.2.2 2020-07-07 22:54:15 +00:00
081347b23b fix(core): update 2020-07-07 22:54:15 +00:00
16 changed files with 10325 additions and 719 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom

View File

@ -24,13 +24,14 @@ mirror:
- docker - docker
- notpriv - notpriv
snyk: audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
tags: tags:
- lossless - lossless
- docker - docker

29
.vscode/launch.json vendored Normal file
View 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
View 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"]
}
}
}
}
}
}
]
}

View File

@ -9,6 +9,7 @@
} }
}, },
"gitzone": { "gitzone": {
"projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",

10863
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
{ {
"name": "@pushrocks/tapbundle", "name": "@pushrocks/tapbundle",
"private": false, "private": false,
"version": "3.2.1", "version": "3.2.6",
"description": "tap bundled for tapbuffer", "description": "tap bundled for tapbuffer",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild)" "build": "(tsbuild --web)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -20,26 +20,27 @@
}, },
"homepage": "https://gitlab.com/pushrocks/tapbundle#README", "homepage": "https://gitlab.com/pushrocks/tapbundle#README",
"dependencies": { "dependencies": {
"@pushrocks/early": "^3.0.3", "@pushrocks/smartdelay": "^2.0.9",
"@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartenv": "^4.0.10",
"@pushrocks/smartfile": "^7.0.9",
"@pushrocks/smartpromise": "^3.0.2", "@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smarttime": "^3.0.19",
"smartchai": "^2.0.1" "smartchai": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.20", "@gitzone/tsbuild": "^2.1.24",
"@gitzone/tsrun": "^1.2.8", "@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.24", "@gitzone/tstest": "^1.0.36",
"@types/node": "^13.9.0", "@types/node": "^14.0.19",
"randomstring": "^1.1.5", "randomstring": "^1.1.5",
"tslint": "^6.1.0", "tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
"ts_web/**/*", "ts_web/**/*",
"dist/**/*", "dist/**/*",
"dist_web/**/*", "dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",

40
test/test.browser.ts Normal file
View File

@ -0,0 +1,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) => {
await tools.delayFor(50);
});
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 > 10).to.be.true;
}
);
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) => {
tools.timeout(1000);
await tools.delayFor(500);
});
const test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async (tools) => {
tools.allowFailure();
tools.timeout(1000);
await tools.delayFor(100);
});
tap.start();

View File

@ -1,7 +1,7 @@
import { tap, expect } from '../ts/index'; import { tap, expect } from '../ts/index';
import * as randomstring from 'randomstring'; import * as randomstring from 'randomstring';
const test1 = tap.test('my first test -> expect true to be true', async tools => { const test1 = tap.test('my first test -> expect true to be true', async (tools) => {
await tools.checkIterationLeak(async () => { await tools.checkIterationLeak(async () => {
const domain = randomstring.generate(1000); const domain = randomstring.generate(1000);
}); });
@ -9,7 +9,7 @@ const test1 = tap.test('my first test -> expect true to be true', async tools =>
const outsideArray = []; const outsideArray = [];
const test2 = tap.test('should throw', async tools => { const test2 = tap.test('should throw', async (tools) => {
const err = await tools.returnError(async () => { const err = await tools.returnError(async () => {
await tools.checkIterationLeak(async () => { await tools.checkIterationLeak(async () => {
outsideArray.push(randomstring.generate(1000)); outsideArray.push(randomstring.generate(1000));

View File

@ -2,13 +2,13 @@ import { tap, expect } from '../ts/index';
tap.preTask('hi there', async () => { tap.preTask('hi there', async () => {
console.log('this is a pretask'); console.log('this is a pretask');
}) });
const test1 = tap.test('my first test -> expect true to be true', async () => { const test1 = tap.test('my first test -> expect true to be true', async () => {
return expect(true).to.be.true; 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); await tools.delayFor(1000);
}); });
@ -21,17 +21,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(); tools.allowFailure();
expect(false).to.be.true; 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); tools.timeout(1000);
await tools.delayFor(500); 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.allowFailure();
tools.timeout(1000); tools.timeout(1000);
await tools.delayFor(2000); await tools.delayFor(2000);

View File

@ -1,7 +1,6 @@
import * as plugins from './tapbundle.plugins'; import * as plugins from './tapbundle.plugins';
import { TapTools } from './tapbundle.classes.taptools'; import { TapTools } from './tapbundle.classes.taptools';
export interface IPreTaskFunction { export interface IPreTaskFunction {
(tapTools?: TapTools): Promise<any>; (tapTools?: TapTools): Promise<any>;
} }
@ -15,8 +14,8 @@ export class PreTask {
this.preTaskFunction = preTaskFunctionArg; this.preTaskFunction = preTaskFunctionArg;
} }
public async run () { public async run() {
console.log(`::__PRETASK: ${this.description}`); console.log(`::__PRETASK: ${this.description}`);
await this.preTaskFunction(new TapTools(null)); await this.preTaskFunction(new TapTools(null));
} }
} }

View File

@ -14,7 +14,7 @@ export class Tap {
}, },
testParallel: (descriptionArg: string, functionArg: ITestFunction) => { testParallel: (descriptionArg: string, functionArg: ITestFunction) => {
console.log(`skipped test: ${descriptionArg}`); console.log(`skipped test: ${descriptionArg}`);
} },
}; };
/** /**
@ -23,7 +23,7 @@ export class Tap {
public only = { public only = {
test: (descriptionArg: string, testFunctionArg: ITestFunction) => { test: (descriptionArg: string, testFunctionArg: ITestFunction) => {
this.test(descriptionArg, testFunctionArg, 'only'); this.test(descriptionArg, testFunctionArg, 'only');
} },
}; };
private _tapPreTasks: PreTask[] = []; private _tapPreTasks: PreTask[] = [];
@ -43,7 +43,7 @@ export class Tap {
const localTest = new TapTest({ const localTest = new TapTest({
description: testDescription, description: testDescription,
testFunction, testFunction,
parallel: false parallel: false,
}); });
if (modeArg === 'normal') { if (modeArg === 'normal') {
this._tapTests.push(localTest); this._tapTests.push(localTest);
@ -53,7 +53,7 @@ export class Tap {
return localTest; return localTest;
} }
public preTask (descriptionArg: string, functionArg: IPreTaskFunction) { public preTask(descriptionArg: string, functionArg: IPreTaskFunction) {
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg)); this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
} }
@ -74,7 +74,7 @@ export class Tap {
new TapTest({ new TapTest({
description: testDescription, description: testDescription,
testFunction, testFunction,
parallel: true parallel: true,
}) })
); );
} }
@ -83,6 +83,13 @@ export class Tap {
* starts the test evaluation * starts the test evaluation
*/ */
public async start(optionsArg?: { throwOnError: boolean }) { 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;
// lets continue with running the tests
const promiseArray: Array<Promise<any>> = []; const promiseArray: Array<Promise<any>> = [];
// safeguard against empty test array // safeguard against empty test array

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 '@pushrocks/early';
import { Deferred } from '@pushrocks/smartpromise'; import { Deferred } from '@pushrocks/smartpromise';
import { HrtMeasurement } from '@pushrocks/smarttime';
// interfaces // interfaces
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout'; export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';

View File

@ -42,10 +42,6 @@ export class TapTools {
} }
} }
public async ensureDir(pathArg: string) {
await plugins.smartfile.fs.ensureDir(pathArg);
}
public async checkIterationLeak(iterationfuncArg: IPromiseFunc) { public async checkIterationLeak(iterationfuncArg: IPromiseFunc) {
console.log('iteration leakage checks disabled for now due to incompatibilities with node v12'); console.log('iteration leakage checks disabled for now due to incompatibilities with node v12');
} }

View File

@ -1,10 +1,9 @@
// pushrocks // pushrocks
import * as early from '@pushrocks/early';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartfile from '@pushrocks/smartfile'; import * as smartenv from '@pushrocks/smartenv';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
export { early, smartfile, smartdelay, smartpromise }; export { smartdelay, smartenv, smartpromise };
// third party // third party
/* import * as leakage from 'leakage'; /* import * as leakage from 'leakage';