Compare commits

...

45 Commits

Author SHA1 Message Date
e9d6e9f9dd 5.0.9 2023-07-13 02:09:54 +02:00
d8e638a07f fix(core): update 2023-07-13 02:09:53 +02:00
85eb222bd9 5.0.8 2023-06-22 13:35:35 +02:00
189c0bae30 fix(core): update 2023-06-22 13:35:35 +02:00
570422ae61 5.0.7 2023-06-22 13:32:44 +02:00
4ba34a4b88 fix(core): update 2023-06-22 13:32:43 +02:00
ae2aabaa86 5.0.6 2022-07-24 15:22:10 +02:00
269a8c974e fix(core): update 2022-07-24 15:22:10 +02:00
10ab777e7f 5.0.5 2022-07-24 14:03:45 +02:00
898eed4584 fix(core): update 2022-07-24 14:03:44 +02:00
7a1eae2bfb 5.0.4 2022-07-24 14:03:30 +02:00
8f7167f201 fix(core): update 2022-07-24 14:03:29 +02:00
6fa151f933 5.0.3 2022-03-24 13:17:20 +01:00
f846b91378 fix(core): update 2022-03-24 13:17:20 +01:00
a0840ee9f4 5.0.2 2022-03-14 13:17:55 +01:00
041534f363 fix(core): update 2022-03-14 13:17:54 +01:00
c89362ba8a 5.0.1 2022-03-14 12:56:17 +01:00
f07879d2c1 fix(core): update 2022-03-14 12:56:17 +01:00
eba3a19488 5.0.0 2022-03-14 11:23:02 +01:00
f83479a407 4.0.9 2022-03-14 11:22:18 +01:00
da711c119f fix(core): update 2022-03-14 11:22:17 +01:00
6690238251 4.0.8 2022-02-28 13:17:00 +01:00
27a794b83c fix(core): update 2022-02-28 13:16:59 +01:00
b3c4a58491 4.0.7 2022-02-15 16:49:29 +01:00
50c34f89ee fix(core): update 2022-02-15 16:49:29 +01:00
b813453c5f 4.0.6 2022-02-15 16:48:59 +01:00
9a6dc33b6b fix(core): update 2022-02-15 16:48:59 +01:00
8bf99ae7ec 4.0.5 2022-02-15 16:48:04 +01:00
cc708b29ae fix(core): update 2022-02-15 16:48:03 +01:00
5798d3e808 4.0.4 2022-02-15 16:40:22 +01:00
37fe299a45 fix(core): update 2022-02-15 16:40:21 +01:00
e24cdd9f0f 4.0.3 2022-02-02 08:11:01 +01:00
ae7aaab456 fix(core): update 2022-02-02 08:11:00 +01:00
bab360cc59 4.0.2 2022-02-02 07:38:27 +01:00
36dcd228fd fix(core): update 2022-02-02 07:38:26 +01:00
c7d6451758 4.0.1 2022-02-02 03:03:03 +01:00
aeedf14336 fix(core): update 2022-02-02 03:03:03 +01:00
14b95cfbc3 4.0.0 2022-01-21 19:54:08 +01:00
0884da7941 BREAKING CHANGE(core): switxh to @pushrocks/smartexpect 2022-01-21 19:54:07 +01:00
22df58b8bc 3.2.15 2021-12-10 17:34:06 +01:00
33399126f7 fix(core): update 2021-12-10 17:34:06 +01:00
d1e46fd2a7 3.2.14 2021-02-13 16:06:38 +00:00
9304e6d736 fix(core): update 2021-02-13 16:06:38 +00:00
588c532d6d 3.2.13 2021-02-13 16:02:40 +00:00
e3a756c775 fix(core): update 2021-02-13 16:02:40 +00:00
20 changed files with 4819 additions and 11574 deletions

View File

@ -12,10 +12,10 @@
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitscope": "push.rocks",
"gitrepo": "tapbundle",
"shortDescription": "tap bundled for tapbuffer",
"npmPackagename": "@pushrocks/tapbundle",
"npmPackagename": "@push.rocks/tapbundle",
"license": "MIT"
}
}

11480
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,14 @@
{
"name": "@pushrocks/tapbundle",
"name": "@push.rocks/tapbundle",
"private": false,
"version": "3.2.12",
"version": "5.0.9",
"description": "tap bundled for tapbuffer",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild --web)"
"build": "(tsbuild --web --allowimplicitany --skiplibcheck)"
},
"repository": {
"type": "git",
@ -20,20 +21,20 @@
},
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
"dependencies": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartenv": "^4.0.16",
"@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smarttime": "^3.0.38",
"smartchai": "^2.0.1"
"@open-wc/testing": "^3.2.0",
"@open-wc/testing-helpers": "^2.3.0",
"@push.rocks/smartdelay": "^3.0.1",
"@push.rocks/smartenv": "^5.0.5",
"@push.rocks/smartexpect": "^1.0.15",
"@push.rocks/smartpromise": "^4.0.2",
"@push.rocks/smarttime": "^4.0.1"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.52",
"@types/node": "^14.14.22",
"randomstring": "^1.1.5",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
"@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.43",
"@gitzone/tstest": "^1.0.72",
"@types/node": "^20.4.2",
"randomstring": "^1.3.0"
},
"files": [
"ts/**/*",

4684
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
# @pushrocks/tapbundle
tap bundled for tapbuffer
tap based testing framework for use with @gitzone/tstest
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/tapbundle)
@ -31,14 +31,17 @@ A few words on TypeScript
### Included in this package
- tap compatible testing framework written in TypeScript
- a collection of test tools
- **code** testing framework with typings
* tap compatible testing framework written in TypeScript
* `expect` and `expectAsync` from the package `@pushrocks/smartexpect`
### A few words on tap
**"tap"** stands for **"test anything protocol"**. Its programming language agnostic as long as the test interpreter can read the tap console output. This package is optimized to work with @gitzone/tstest as interpreter, which offers different V8 based runtime environments like nodejs, chrome, and deno.
### Write your first tests
```javascript
import { tap, expect } from 'tapbundle'; // has typings in place
```typescript
import { tap, expect, expectAsync } from 'tapbundle'; // has typings in place
import * as myAwesomeModuleToTest from '../dist/index'; // '../dist/index' is the standard path for npmts modules
@ -47,25 +50,27 @@ tap.test('my awesome description', async (tools) => {
tools.timeout(2000); // test will fail if it takes longer than 2000 millisenconds
});
let myTest2 = tap.test('my awesome test 2', async (tools) => {
const 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) => {
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 :)
expect(true).toBeTrue(); // will not throw
await expectAsync(tools.delayFor(2000)).toBeUndefined(); // yay expect promises :)
expectAsync(myTest2.promise) // access other tests metadata :)
.property('hrtMeasurement') // and drill down into properties
.property('milliSeconds').toBeGreaterThan(1000);
});
let myTest4 = tap.testParallel('my awesome test 4', async (tools) => {
const myTest4 = tap.testParallel('my awesome test 4', async (tools) => {
await tools.delayFor(4000);
console.log('logs to console after 4 seconds into this test');
});
tap.test('my awesome test 5', async () => {
expect(myTest4.status).to.equal('pending'); // since this test will likely finish before myTest4.
expect(myTest4.status).toEqual('pending'); // since this test will likely finish before myTest4.
});
tap.start(); // start the test, will automtically plan tests for you (so the tap parser knows when tests exit bofore they are finished)

View File

@ -1,11 +1,17 @@
import { tap, expect } from '../ts/index';
import { tap, expect, webhelpers } from '../ts/index.js';
tap.preTask('hi there', async () => {
tap.preTask('custompretask', async () => {
console.log('this is a pretask');
});
tap.test('should have access to webhelpers', async () => {
const myElement = await webhelpers.fixture(webhelpers.html`<div></div>`);
expect(myElement).toBeInstanceOf(HTMLElement);
console.log(myElement);
});
const test1 = tap.test('my first test -> expect true to be true', async () => {
return expect(true).to.be.true;
return expect(true).toBeTrue();
});
const test2 = tap.test('my second test', async (tools) => {
@ -15,15 +21,14 @@ const test2 = tap.test('my second test', async (tools) => {
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;
expect((await test1.testPromise).hrtMeasurement.milliSeconds < (await test2).hrtMeasurement.milliSeconds).toBeTrue();
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 10).toBeTrue();
}
);
const test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
tools.allowFailure();
expect(false).to.be.true;
expect(false).toBeTrue();
});
const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {

View File

@ -1,4 +1,4 @@
import { tap, expect, TapWrap } from '../ts/index';
import { tap, expect, TapWrap } from '../ts/index.js';
tap.test('should run a test', async () => {});

View File

@ -1,11 +1,11 @@
import { tap, expect } from '../ts/index';
import { tap, expect } from '../ts/index.js';
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;
return expect(true).toBeTrue();
});
const test2 = tap.test('my second test', async (tools) => {
@ -18,14 +18,14 @@ const test3 = tap.test(
expect(
(await test1.testPromise).hrtMeasurement.milliSeconds <
(await test2).hrtMeasurement.milliSeconds
).to.be.true;
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).to.be.true;
).toBeTrue();
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).toBeTrue();
}
);
const test4 = tap.test('my 4th test -> should fail', async (tools) => {
tools.allowFailure();
expect(false).to.be.true;
expect(false).toBeFalse();
return 'hello';
});

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/tapbundle',
version: '5.0.9',
description: 'tap bundled for tapbuffer'
}

View File

@ -1,3 +1,10 @@
export { expect } from 'smartchai';
export { tap } from './tapbundle.classes.tap';
export { TapWrap } from './tapbundle.classes.tapwrap';
export { tap } from './tapbundle.classes.tap.js';
export { TapWrap } from './tapbundle.classes.tapwrap.js';
export { webhelpers } from './webhelpers.js';
import { expect, expectAsync } from '@push.rocks/smartexpect';
export {
expect,
expectAsync
}

View File

@ -1,5 +1,5 @@
import * as plugins from './tapbundle.plugins';
import { TapTools } from './tapbundle.classes.taptools';
import * as plugins from './tapbundle.plugins.js';
import { TapTools } from './tapbundle.classes.taptools.js';
export interface IPreTaskFunction {
(tapTools?: TapTools): Promise<any>;

View File

@ -1,8 +1,8 @@
import * as plugins from './tapbundle.plugins';
import * as plugins from './tapbundle.plugins.js';
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask';
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
export class Tap <T> {
import { type IPreTaskFunction, PreTask } from './tapbundle.classes.pretask.js';
import { TapTest, type ITestFunction } from './tapbundle.classes.taptest.js';
export class Tap<T> {
/**
* skips a test
* tests marked with tap.skip.test() are never executed
@ -78,7 +78,7 @@ export class Tap <T> {
// lets set the tapbundle promise
const smartenvInstance = new plugins.smartenv.Smartenv();
smartenvInstance.isBrowser
? (globalThis.tapbundleDeferred = plugins.smartpromise.defer())
? ((globalThis as any).tapbundleDeferred = plugins.smartpromise.defer())
: null;
// lets continue with running the tests
@ -139,14 +139,14 @@ export class Tap <T> {
if (!smartenvInstance.isBrowser) process.exit(1);
}
if (smartenvInstance.isBrowser) {
globalThis.tapbundleDeferred.resolve();
(globalThis as any).tapbundleDeferred.resolve();
}
}
/**
* handle errors
*/
public threw(err) {
public threw(err: Error) {
console.log(err);
}
}

View File

@ -1,10 +1,10 @@
import * as plugins from './tapbundle.plugins';
import { tapCreator } from './tapbundle.tapcreator';
import { TapTools } from './tapbundle.classes.taptools';
import * as plugins from './tapbundle.plugins.js';
import { tapCreator } from './tapbundle.tapcreator.js';
import { TapTools } from './tapbundle.classes.taptools.js';
// imported interfaces
import { Deferred } from '@pushrocks/smartpromise';
import { HrtMeasurement } from '@pushrocks/smarttime';
import { Deferred } from '@push.rocks/smartpromise';
import { HrtMeasurement } from '@push.rocks/smarttime';
// interfaces
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
@ -55,7 +55,7 @@ export class TapTest <T = unknown> {
this.status = 'success';
this.testDeferred.resolve(this);
this.testResultDeferred.resolve(testReturnValue);
} catch (err) {
} catch (err: any) {
this.hrtMeasurement.stop();
console.log(
`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`

View File

@ -1,5 +1,5 @@
import * as plugins from './tapbundle.plugins';
import { TapTest } from './tapbundle.classes.taptest';
import * as plugins from './tapbundle.plugins.js';
import { TapTest } from './tapbundle.classes.taptest.js';
export interface IPromiseFunc {
(): Promise<any>;
@ -11,7 +11,7 @@ export class TapTools {
*/
private _tapTest: TapTest;
constructor(TapTestArg) {
constructor(TapTestArg: TapTest<any>) {
this._tapTest = TapTestArg;
}
@ -25,11 +25,11 @@ export class TapTools {
/**
* async/await delay method
*/
public async delayFor(timeMilliArg) {
public async delayFor(timeMilliArg: number) {
await plugins.smartdelay.delayFor(timeMilliArg);
}
public async delayForRandom(timeMilliMinArg, timeMilliMaxArg) {
public async delayForRandom(timeMilliMinArg: number, timeMilliMaxArg: number) {
await plugins.smartdelay.delayForRandom(timeMilliMinArg, timeMilliMaxArg);
}
@ -46,7 +46,7 @@ export class TapTools {
let funcErr: Error;
try {
await throwingFuncArg();
} catch (err) {
} catch (err: any) {
funcErr = err;
}
return funcErr;

View File

@ -1,4 +1,4 @@
import * as plugins from './tapbundle.plugins';
import * as plugins from './tapbundle.plugins.js';
export interface ITapWrapOptions {
before: () => Promise<any>;

View File

@ -1,11 +1,7 @@
// pushrocks
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartenv from '@pushrocks/smartenv';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartdelay from '@push.rocks/smartdelay';
import * as smartenv from '@push.rocks/smartenv';
import * as smartexpect from '@push.rocks/smartexpect';
import * as smartpromise from '@push.rocks/smartpromise';
export { smartdelay, smartenv, smartpromise };
// third party
/* import * as leakage from 'leakage';
export { leakage }; */
export { smartdelay, smartenv, smartexpect, smartpromise };

View File

@ -1,4 +1,4 @@
import * as plugins from './tapbundle.plugins';
import * as plugins from './tapbundle.plugins.js';
export class TapCreator {
// TODO:

25
ts/webhelpers.ts Normal file
View File

@ -0,0 +1,25 @@
import * as plugins from './tapbundle.plugins.js';
import type { fixture, html } from '@open-wc/testing-helpers';
import { tap } from './tapbundle.classes.tap.js';
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');
this.html = webhelpers.html;
this.fixture = webhelpers.fixture;
})
}
}
export const webhelpers = new WebHelpers();

11
tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}