diff --git a/.gitignore b/.gitignore index 91c0db0..ef13c79 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,6 @@ node_modules/ # builds dist/ -dist_web/ -dist_serve/ -dist_ts_web/ +dist_*/ # custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b14b4ac..8ebc8b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,13 +24,14 @@ mirror: - docker - notpriv -snyk: +audit: + 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 config set registry https://registry.npmjs.org + - npmci command npm audit --audit-level=high tags: - lossless - docker diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..112db52 --- /dev/null +++ b/.vscode/launch.json @@ -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" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..01d2b8d --- /dev/null +++ b/.vscode/settings.json @@ -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"] + } + } + } + } + } + } + ] +} diff --git a/README.md b/README.md deleted file mode 100644 index a5ed2e4..0000000 --- a/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# @pushrocks/tapbundle -tap bundled for tapbuffer - -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/tapbundle) -* [gitlab.com (source)](https://gitlab.com/pushrocks/tapbundle) -* [github.com (source mirror)](https://github.com/pushrocks/tapbundle) -* [docs (typedoc)](https://pushrocks.gitlab.io/tapbundle/) - -## Status for master -[![build status](https://gitlab.com/pushrocks/tapbundle/badges/master/build.svg)](https://gitlab.com/pushrocks/tapbundle/commits/master) -[![coverage report](https://gitlab.com/pushrocks/tapbundle/badges/master/coverage.svg)](https://gitlab.com/pushrocks/tapbundle/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/tapbundle.svg)](https://www.npmjs.com/package/@pushrocks/tapbundle) -[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/tapbundle/badge.svg)](https://snyk.io/test/npm/@pushrocks/tapbundle) -[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) - -## Usage - -Use TypeScript for best in class instellisense. - -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 - -### Write your first tests - -```javascript -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 => { - // 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 => { - 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 :) -}); - -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'); -}); - -tap.test('my awesome test 5', async () => { - expect(myTest4.status).to.equal('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) -``` - -## Contribution - -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) - -For further information read the linked docs at the top of this readme. - -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) - -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) diff --git a/npmextra.json b/npmextra.json index df6acac..f80b407 100644 --- a/npmextra.json +++ b/npmextra.json @@ -9,6 +9,7 @@ } }, "gitzone": { + "projectType": "npm", "module": { "githost": "gitlab.com", "gitscope": "pushrocks", diff --git a/package.json b/package.json index 7a1269e..74a51ff 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "private": false, "version": "3.2.5", "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)" @@ -39,11 +39,12 @@ "ts/**/*", "ts_web/**/*", "dist/**/*", - "dist_web/**/*", + "dist_*/**/*", + "dist_ts/**/*", "dist_ts_web/**/*", "assets/**/*", "cli.js", "npmextra.json", "readme.md" ] -} +} \ No newline at end of file diff --git a/test/test.browser.ts b/test/test.browser.ts index fa1bee9..f766bcf 100644 --- a/test/test.browser.ts +++ b/test/test.browser.ts @@ -8,7 +8,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 +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(); 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); diff --git a/test/test.iterationleak.ts b/test/test.iterationleak.ts index 0d3fad7..a91c4b2 100644 --- a/test/test.iterationleak.ts +++ b/test/test.iterationleak.ts @@ -1,7 +1,7 @@ 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 => { +const test1 = tap.test('my first test -> expect true to be true', async (tools) => { await tools.checkIterationLeak(async () => { 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 test2 = tap.test('should throw', async tools => { +const test2 = tap.test('should throw', async (tools) => { const err = await tools.returnError(async () => { await tools.checkIterationLeak(async () => { outsideArray.push(randomstring.generate(1000)); diff --git a/test/test.ts b/test/test.ts index a1b84bd..0a2317e 100644 --- a/test/test.ts +++ b/test/test.ts @@ -2,13 +2,13 @@ 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); }); @@ -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(); 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(2000); diff --git a/ts/tapbundle.classes.pretask.ts b/ts/tapbundle.classes.pretask.ts index f43352d..4d87b1a 100644 --- a/ts/tapbundle.classes.pretask.ts +++ b/ts/tapbundle.classes.pretask.ts @@ -1,7 +1,6 @@ import * as plugins from './tapbundle.plugins'; import { TapTools } from './tapbundle.classes.taptools'; - export interface IPreTaskFunction { (tapTools?: TapTools): Promise; } @@ -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)); } -} \ No newline at end of file +} diff --git a/ts/tapbundle.classes.tap.ts b/ts/tapbundle.classes.tap.ts index 675ea37..bbf586f 100644 --- a/ts/tapbundle.classes.tap.ts +++ b/ts/tapbundle.classes.tap.ts @@ -14,7 +14,7 @@ export class Tap { }, testParallel: (descriptionArg: string, functionArg: ITestFunction) => { console.log(`skipped test: ${descriptionArg}`); - } + }, }; /** @@ -23,7 +23,7 @@ export class Tap { public only = { test: (descriptionArg: string, testFunctionArg: ITestFunction) => { this.test(descriptionArg, testFunctionArg, 'only'); - } + }, }; private _tapPreTasks: PreTask[] = []; @@ -43,7 +43,7 @@ export class Tap { const localTest = new TapTest({ description: testDescription, testFunction, - parallel: false + parallel: false, }); if (modeArg === 'normal') { this._tapTests.push(localTest); @@ -53,7 +53,7 @@ export class Tap { return localTest; } - public preTask (descriptionArg: string, functionArg: IPreTaskFunction) { + public preTask(descriptionArg: string, functionArg: IPreTaskFunction) { this._tapPreTasks.push(new PreTask(descriptionArg, functionArg)); } @@ -74,7 +74,7 @@ export class Tap { new TapTest({ description: testDescription, testFunction, - parallel: true + parallel: true, }) ); } @@ -85,7 +85,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> = []; diff --git a/ts/tapbundle.classes.taptest.ts b/ts/tapbundle.classes.taptest.ts index d735234..5c1e158 100644 --- a/ts/tapbundle.classes.taptest.ts +++ b/ts/tapbundle.classes.taptest.ts @@ -42,7 +42,6 @@ export class TapTest { 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...');