Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
45ee6eca31 | |||
1eaf1e9a77 | |||
715108b11b | |||
7b1e8f47b1 | |||
2b71ffe8c2 | |||
29ec99e63e | |||
50f1aad895 | |||
f7e95df2b9 |
@ -19,23 +19,35 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
audit:
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- 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:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
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 --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -50,9 +62,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -63,9 +73,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -85,6 +93,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- 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: {}
|
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3770
package-lock.json
generated
3770
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/tapbundle",
|
"name": "@pushrocks/tapbundle",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "3.2.6",
|
"version": "3.2.10",
|
||||||
"description": "tap bundled for tapbuffer",
|
"description": "tap bundled for tapbuffer",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@ -20,19 +20,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.9",
|
"@pushrocks/smartdelay": "^2.0.10",
|
||||||
"@pushrocks/smartenv": "^4.0.10",
|
"@pushrocks/smartenv": "^4.0.16",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.1.3",
|
||||||
"@pushrocks/smarttime": "^3.0.19",
|
"@pushrocks/smarttime": "^3.0.38",
|
||||||
"smartchai": "^2.0.1"
|
"smartchai": "^2.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
"@gitzone/tstest": "^1.0.36",
|
"@gitzone/tstest": "^1.0.52",
|
||||||
"@types/node": "^14.0.19",
|
"@types/node": "^14.14.22",
|
||||||
"randomstring": "^1.1.5",
|
"randomstring": "^1.1.5",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
@ -46,5 +46,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
29
readme.md
29
readme.md
@ -8,13 +8,20 @@ tap bundled for tapbuffer
|
|||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/tapbundle/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/tapbundle/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/tapbundle/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/tapbundle/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@pushrocks/tapbundle)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@pushrocks/tapbundle)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
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
|
## 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
|
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 are optional parameter
|
||||||
tools.timeout(2000); // test will fail if it takes longer than 2000 millisenconds
|
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
|
myAwsomeModuleToTest.doSomethingAsync(); // we don't wait here
|
||||||
await tools.delayFor(3000); // yay! :) promise based timeouts :)
|
await tools.delayFor(3000); // yay! :) promise based timeouts :)
|
||||||
console.log('This gets logged 3000 ms into the test');
|
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
|
expect(true).to.be.true; // will not throw
|
||||||
await expect(tools.delayFor(2000)).to.eventually.be.fulfilled; // yay expect promises :)
|
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 :)
|
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);
|
await tools.delayFor(4000);
|
||||||
console.log('logs to console after 4 seconds into this test');
|
console.log('logs to console after 4 seconds into this test');
|
||||||
});
|
});
|
||||||
|
@ -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 run a test', async () => {});
|
||||||
tap.test('should do something', async () => {
|
|
||||||
console.log('test1');
|
|
||||||
});
|
|
||||||
tap.start();
|
|
||||||
});
|
|
||||||
|
|
||||||
tapwrap.run();
|
tap.start();
|
||||||
|
@ -15,9 +15,11 @@ const test2 = tap.test('my second test', async (tools) => {
|
|||||||
const test3 = tap.test(
|
const test3 = tap.test(
|
||||||
'my third test -> test2 should take longer than test1 and endure at least 1000ms',
|
'my third test -> test2 should take longer than test1 and endure at least 1000ms',
|
||||||
async () => {
|
async () => {
|
||||||
expect((await test1).hrtMeasurement.milliSeconds < (await test2).hrtMeasurement.milliSeconds).to
|
expect(
|
||||||
.be.true;
|
(await test1.testPromise).hrtMeasurement.milliSeconds <
|
||||||
expect((await test2).hrtMeasurement.milliSeconds > 1000).to.be.true;
|
(await test2).hrtMeasurement.milliSeconds
|
||||||
|
).to.be.true;
|
||||||
|
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).to.be.true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export { expect } from 'smartchai';
|
export { expect } from 'smartchai';
|
||||||
export { tap } from './tapbundle.classes.tap';
|
export { tap } from './tapbundle.classes.tap';
|
||||||
|
export { TapWrap } from './tapbundle.classes.tapwrap';
|
||||||
|
@ -2,7 +2,6 @@ import * as plugins from './tapbundle.plugins';
|
|||||||
|
|
||||||
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask';
|
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask';
|
||||||
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
||||||
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
|
|
||||||
export class Tap {
|
export class Tap {
|
||||||
/**
|
/**
|
||||||
* skips a test
|
* skips a test
|
||||||
@ -35,7 +34,7 @@ export class Tap {
|
|||||||
* @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
|
||||||
*/
|
*/
|
||||||
public async test(
|
public test(
|
||||||
testDescription: string,
|
testDescription: string,
|
||||||
testFunction: ITestFunction,
|
testFunction: ITestFunction,
|
||||||
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
||||||
@ -57,13 +56,6 @@ export class Tap {
|
|||||||
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
|
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.
|
* A parallel test that will not be waited for before the next starts.
|
||||||
* @param testDescription - A description of what the test does
|
* @param testDescription - A description of what the test does
|
||||||
@ -144,7 +136,10 @@ export class Tap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (optionsArg && optionsArg.throwOnError && failReasons.length > 0) {
|
if (optionsArg && optionsArg.throwOnError && failReasons.length > 0) {
|
||||||
process.exit(1);
|
if (!smartenvInstance.isBrowser) process.exit(1);
|
||||||
|
}
|
||||||
|
if (smartenvInstance.isBrowser) {
|
||||||
|
globalThis.tapbundleDeferred.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,10 @@ export class TapTest {
|
|||||||
public tapTools: TapTools;
|
public tapTools: TapTools;
|
||||||
public testFunction: ITestFunction;
|
public testFunction: ITestFunction;
|
||||||
public testKey: number; // the testKey the position in the test qeue. Set upon calling .run()
|
public testKey: number; // the testKey the position in the test qeue. Set upon calling .run()
|
||||||
public testDeferred: Deferred<TapTest> = plugins.smartpromise.defer();
|
private testDeferred: Deferred<TapTest> = plugins.smartpromise.defer();
|
||||||
public testPromise: Promise<TapTest> = this.testDeferred.promise;
|
public testPromise: Promise<TapTest> = this.testDeferred.promise;
|
||||||
|
private testResultDeferred: Deferred<any> = plugins.smartpromise.defer();
|
||||||
|
public testResultPromise: Promise<any> = this.testResultDeferred.promise;
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*/
|
*/
|
||||||
@ -42,7 +44,7 @@ export class TapTest {
|
|||||||
this.testKey = testKeyArg;
|
this.testKey = testKeyArg;
|
||||||
const testNumber = testKeyArg + 1;
|
const testNumber = testKeyArg + 1;
|
||||||
try {
|
try {
|
||||||
await this.testFunction(this.tapTools);
|
const testReturnValue = await this.testFunction(this.tapTools);
|
||||||
if (this.status === 'timeout') {
|
if (this.status === 'timeout') {
|
||||||
throw new Error('Test succeeded, but timed out...');
|
throw new Error('Test succeeded, but timed out...');
|
||||||
}
|
}
|
||||||
@ -52,12 +54,14 @@ export class TapTest {
|
|||||||
);
|
);
|
||||||
this.status = 'success';
|
this.status = 'success';
|
||||||
this.testDeferred.resolve(this);
|
this.testDeferred.resolve(this);
|
||||||
|
this.testResultDeferred.resolve(testReturnValue);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.hrtMeasurement.stop();
|
this.hrtMeasurement.stop();
|
||||||
console.log(
|
console.log(
|
||||||
`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`
|
`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`
|
||||||
);
|
);
|
||||||
this.testDeferred.resolve(this);
|
this.testDeferred.resolve(this);
|
||||||
|
this.testResultDeferred.resolve(err);
|
||||||
|
|
||||||
// if the test has already succeeded before
|
// if the test has already succeeded before
|
||||||
if (this.status === 'success') {
|
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) {
|
public async returnError(throwingFuncArg: IPromiseFunc) {
|
||||||
let funcErr: Error;
|
let funcErr: Error;
|
||||||
try {
|
try {
|
||||||
|
@ -1,25 +1,13 @@
|
|||||||
import * as plugins from './tapbundle.plugins';
|
import * as plugins from './tapbundle.plugins';
|
||||||
|
|
||||||
export interface ITapWrapFunction {
|
export interface ITapWrapOptions {
|
||||||
(): Promise<any>;
|
before: () => Promise<any>;
|
||||||
|
after: () => {};
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TapWrap {
|
export class TapWrap {
|
||||||
wrapFunction: ITapWrapFunction;
|
public options: ITapWrapOptions;
|
||||||
|
constructor(optionsArg: ITapWrapOptions) {
|
||||||
/**
|
this.options = optionsArg;
|
||||||
* 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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user