Compare commits

...

20 Commits

Author SHA1 Message Date
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
10 changed files with 19777 additions and 3404 deletions

23070
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{ {
"name": "@pushrocks/tapbundle", "name": "@pushrocks/tapbundle",
"private": false, "private": false,
"version": "3.2.13", "version": "4.0.7",
"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": {
"@open-wc/testing-helpers": "^1.8.12", "@open-wc/testing-helpers": "^2.0.4",
"@pushrocks/smartdelay": "^2.0.10", "@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartenv": "^4.0.16", "@pushrocks/smartenv": "^4.0.16",
"@pushrocks/smartpromise": "^3.1.3", "@pushrocks/smartexpect": "^1.0.12",
"@pushrocks/smarttime": "^3.0.38", "@pushrocks/smartpromise": "^3.1.6",
"smartchai": "^2.0.1" "@pushrocks/smarttime": "^3.0.45"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.29",
"@gitzone/tsrun": "^1.2.12", "@gitzone/tsrun": "^1.2.18",
"@gitzone/tstest": "^1.0.52", "@gitzone/tstest": "^1.0.64",
"@types/node": "^14.14.22", "@types/node": "^17.0.18",
"randomstring": "^1.1.5", "randomstring": "^1.2.2",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },

View File

@ -1,5 +1,5 @@
# @pushrocks/tapbundle # @pushrocks/tapbundle
tap bundled for tapbuffer tap based testing framework for use with @gitzone/tstest
## Availabililty and Links ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/tapbundle) * [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/tapbundle)
@ -31,14 +31,17 @@ A few words on TypeScript
### Included in this package ### Included in this package
- tap compatible testing framework written in TypeScript * tap compatible testing framework written in TypeScript
- a collection of test tools * `expect` and `expectAsync` from the package `@pushrocks/smartexpect`
- **code** testing framework with typings
### 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 ### Write your first tests
```javascript ```typescript
import { tap, expect } from 'tapbundle'; // has typings in place 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 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 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 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).toBeTrue(); // will not throw
await expect(tools.delayFor(2000)).to.eventually.be.fulfilled; // yay expect promises :) await expectAsync(tools.delayFor(2000)).toBeUndefined(); // yay expect promises :)
expect((await myTest2.promise).hrtMeasurement.milliSeconds > 1000).to.be.true; // access other tests metadata :) 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); 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');
}); });
tap.test('my awesome test 5', async () => { 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) 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,12 +1,17 @@
import { tap, expect, webhelpers } from '../ts/index'; import { tap, expect, webhelpers } from '../ts/index';
tap.preTask('hi there', async () => { tap.preTask('custompretask', async () => {
const myElement = webhelpers.fixture(webhelpers.html`<div></div>`);
console.log('this is a pretask'); 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 () => { 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) => { const test2 = tap.test('my second test', async (tools) => {
@ -16,15 +21,14 @@ 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((await test1).hrtMeasurement.milliSeconds < (await test2).hrtMeasurement.milliSeconds).toBeTrue();
.be.true; expect((await test2).hrtMeasurement.milliSeconds > 10).toBeTrue();
expect((await test2).hrtMeasurement.milliSeconds > 10).to.be.true;
} }
); );
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).toBeTrue();
}); });
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) => {

View File

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

View File

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

View File

@ -78,7 +78,7 @@ export class Tap <T> {
// lets set the tapbundle promise // lets set the tapbundle promise
const smartenvInstance = new plugins.smartenv.Smartenv(); const smartenvInstance = new plugins.smartenv.Smartenv();
smartenvInstance.isBrowser smartenvInstance.isBrowser
? (globalThis.tapbundleDeferred = plugins.smartpromise.defer()) ? ((globalThis as any).tapbundleDeferred = plugins.smartpromise.defer())
: null; : null;
// lets continue with running the tests // lets continue with running the tests
@ -139,14 +139,14 @@ export class Tap <T> {
if (!smartenvInstance.isBrowser) process.exit(1); if (!smartenvInstance.isBrowser) process.exit(1);
} }
if (smartenvInstance.isBrowser) { if (smartenvInstance.isBrowser) {
globalThis.tapbundleDeferred.resolve(); (globalThis as any).tapbundleDeferred.resolve();
} }
} }
/** /**
* handle errors * handle errors
*/ */
public threw(err) { public threw(err: Error) {
console.log(err); console.log(err);
} }
} }

View File

@ -55,7 +55,7 @@ export class TapTest <T = unknown> {
this.status = 'success'; this.status = 'success';
this.testDeferred.resolve(this); this.testDeferred.resolve(this);
this.testResultDeferred.resolve(testReturnValue); this.testResultDeferred.resolve(testReturnValue);
} catch (err) { } catch (err: any) {
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`

View File

@ -11,7 +11,7 @@ export class TapTools {
*/ */
private _tapTest: TapTest; private _tapTest: TapTest;
constructor(TapTestArg) { constructor(TapTestArg: TapTest<any>) {
this._tapTest = TapTestArg; this._tapTest = TapTestArg;
} }
@ -25,11 +25,11 @@ export class TapTools {
/** /**
* async/await delay method * async/await delay method
*/ */
public async delayFor(timeMilliArg) { public async delayFor(timeMilliArg: number) {
await plugins.smartdelay.delayFor(timeMilliArg); await plugins.smartdelay.delayFor(timeMilliArg);
} }
public async delayForRandom(timeMilliMinArg, timeMilliMaxArg) { public async delayForRandom(timeMilliMinArg: number, timeMilliMaxArg: number) {
await plugins.smartdelay.delayForRandom(timeMilliMinArg, timeMilliMaxArg); await plugins.smartdelay.delayForRandom(timeMilliMinArg, timeMilliMaxArg);
} }
@ -46,7 +46,7 @@ export class TapTools {
let funcErr: Error; let funcErr: Error;
try { try {
await throwingFuncArg(); await throwingFuncArg();
} catch (err) { } catch (err: any) {
funcErr = err; funcErr = err;
} }
return funcErr; return funcErr;

View File

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