Compare commits

...

77 Commits

Author SHA1 Message Date
c97215ed2d 5.0.20 2024-03-19 13:43:34 +01:00
6dbe5098de fix(core): update 2024-03-19 13:43:34 +01:00
3e9a288333 5.0.19 2024-03-19 13:34:57 +01:00
07b876ea2c fix(core): update 2024-03-19 13:34:56 +01:00
28fec7a488 5.0.18 2024-03-19 13:13:57 +01:00
b99ac03942 fix(core): update 2024-03-19 13:13:56 +01:00
ba6519adb5 5.0.17 2024-03-13 22:13:31 +01:00
2de0e63b3c fix(core): update 2024-03-13 22:13:30 +01:00
2359841a15 5.0.16 2024-03-13 22:07:58 +01:00
0ef865ea9f fix(core): update 2024-03-13 22:07:58 +01:00
a8beda7597 5.0.15 2023-08-12 11:40:29 +02:00
e029c8601f fix(core): update 2023-08-12 11:40:29 +02:00
1b9f414e82 5.0.14 2023-08-12 11:39:09 +02:00
1aa4152de2 fix(core): update 2023-08-12 11:39:09 +02:00
b93e962bdf 5.0.13 2023-07-13 03:18:09 +02:00
0faf2ce3df fix(core): update 2023-07-13 03:18:08 +02:00
831f67053e 5.0.12 2023-07-13 02:41:11 +02:00
26e63372f8 fix(core): update 2023-07-13 02:41:10 +02:00
929a67585f 5.0.11 2023-07-13 02:40:10 +02:00
fb8d291441 fix(core): update 2023-07-13 02:40:09 +02:00
5657b49a51 5.0.10 2023-07-13 02:39:42 +02:00
db39da1faf fix(core): update 2023-07-13 02:39:42 +02:00
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
05defe6031 3.2.12 2021-01-26 03:19:50 +00:00
f4bb17dea1 fix(core): update 2021-01-26 03:19:49 +00:00
1023a94ff2 3.2.11 2021-01-26 03:15:50 +00:00
8ee456da5f fix(core): update 2021-01-26 03:15:50 +00:00
45ee6eca31 3.2.10 2021-01-26 02:35:03 +00:00
1eaf1e9a77 fix(core): update 2021-01-26 02:35:02 +00:00
715108b11b 3.2.9 2020-07-11 16:07:53 +00:00
7b1e8f47b1 fix(core): update 2020-07-11 16:07:52 +00:00
2b71ffe8c2 3.2.8 2020-07-11 16:07:31 +00:00
29ec99e63e fix(core): update 2020-07-11 16:07:30 +00:00
27 changed files with 5927 additions and 11328 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

View File

@ -1,127 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- lossless
- docker
- notpriv
audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
tags:
- lossless
- docker
- notpriv
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

15
.snyk
View File

@ -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: {}

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${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"
} }
] ]
} }

View File

@ -15,7 +15,7 @@
"properties": { "properties": {
"projectType": { "projectType": {
"type": "string", "type": "string",
"enum": ["website", "element", "service", "npm"] "enum": ["website", "element", "service", "npm", "wcc"]
} }
} }
} }

View File

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

10978
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,15 @@
{ {
"name": "@pushrocks/tapbundle", "name": "@push.rocks/tapbundle",
"private": false, "private": false,
"version": "3.2.7", "version": "5.0.20",
"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",
"type": "module",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web)" "build": "(tsbuild --web --allowimplicitany --skiplibcheck)",
"buildDocs": "tsdoc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -20,20 +22,21 @@
}, },
"homepage": "https://gitlab.com/pushrocks/tapbundle#README", "homepage": "https://gitlab.com/pushrocks/tapbundle#README",
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.9", "@open-wc/testing": "^4.0.0",
"@pushrocks/smartenv": "^4.0.10", "@push.rocks/consolecolor": "^2.0.2",
"@pushrocks/smartpromise": "^3.0.2", "@push.rocks/smartdelay": "^3.0.5",
"@pushrocks/smarttime": "^3.0.19", "@push.rocks/smartenv": "^5.0.12",
"smartchai": "^2.0.1" "@push.rocks/smartexpect": "^1.0.21",
"@push.rocks/smartjson": "^5.0.15",
"@push.rocks/smartpromise": "^4.0.2",
"@push.rocks/smarttime": "^4.0.6"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.24", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.12", "@gitzone/tsrun": "^1.2.43",
"@gitzone/tstest": "^1.0.36", "@gitzone/tstest": "^1.0.77",
"@types/node": "^14.0.19", "@types/node": "^20.11.29",
"randomstring": "^1.1.5", "randomstring": "^1.3.0"
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@ -46,5 +49,8 @@
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
],
"browserslist": [
"last 1 chrome versions"
] ]
} }

5514
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,26 @@
# @pushrocks/tapbundle # @push.rocks/tapbundle
tap bundled for tapbuffer tap bundled for tapbuffer
## 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/@push.rocks/tapbundle)
* [gitlab.com (source)](https://gitlab.com/pushrocks/tapbundle) * [gitlab.com (source)](https://gitlab.com/push.rocks/tapbundle)
* [github.com (source mirror)](https://github.com/pushrocks/tapbundle) * [github.com (source mirror)](https://github.com/push.rocks/tapbundle)
* [docs (typedoc)](https://pushrocks.gitlab.io/tapbundle/) * [docs (typedoc)](https://push.rocks.gitlab.io/tapbundle/)
## Status for master ## 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) Status Category | Status Badge
[![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) GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/tapbundle/badges/master/pipeline.svg)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/tapbundle/badges/master/coverage.svg)](https://lossless.cloud)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/tapbundle)](https://lossless.cloud)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/tapbundle)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/tapbundle)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/tapbundle)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/tapbundle)](https://lossless.cloud)
## Usage ## Usage
@ -25,40 +31,46 @@ 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
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 => { 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)
@ -70,7 +82,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | 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)

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'); 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) => {
@ -15,15 +21,17 @@ 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 > 10).to.be.true; (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) => { 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

@ -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();

View File

@ -1,10 +1,5 @@
import { tap, expect } from '../ts/index'; import { tap, expect, TapWrap } from '../ts/index.js';
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();

View File

@ -1,11 +1,11 @@
import { tap, expect } from '../ts/index'; import { tap, expect } from '../ts/index.js';
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).toBeTrue();
}); });
const test2 = tap.test('my second test', async (tools) => { const test2 = tap.test('my second test', async (tools) => {
@ -15,18 +15,22 @@ 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
).toBeTrue();
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).toBeTrue();
} }
); );
const test4 = tap.skip.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.true; expect(false).toBeFalse();
return 'hello';
}); });
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) => {
const test4Result = await test4.testResultPromise;
tools.timeout(1000); tools.timeout(1000);
await tools.delayFor(500); await tools.delayFor(500);
}); });
@ -37,4 +41,9 @@ const test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async (to
await tools.delayFor(2000); await tools.delayFor(2000);
}); });
const test7 = tap.test('my 7th test -> should print a colored string', async (tools) => {
const cs = await tools.coloredString('hello', 'red', 'cyan');
console.log(cs);
});
tap.start(); tap.start();

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.20',
description: 'tap bundled for tapbuffer'
}

View File

@ -1,2 +1,7 @@
export { expect } from 'smartchai'; export { tap } from './tapbundle.classes.tap.js';
export { tap } from './tapbundle.classes.tap'; 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 * as plugins from './tapbundle.plugins.js';
import { TapTools } from './tapbundle.classes.taptools'; import { TapTools } from './tapbundle.classes.taptools.js';
export interface IPreTaskFunction { export interface IPreTaskFunction {
(tapTools?: TapTools): Promise<any>; (tapTools?: TapTools): Promise<any>;

View File

@ -1,18 +1,17 @@
import * as plugins from './tapbundle.plugins'; import * as plugins from './tapbundle.plugins.js';
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask'; import { type IPreTaskFunction, PreTask } from './tapbundle.classes.pretask.js';
import { TapTest, ITestFunction } from './tapbundle.classes.taptest'; import { TapTest, type ITestFunction } from './tapbundle.classes.taptest.js';
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap'; export class Tap<T> {
export class Tap {
/** /**
* skips a test * skips a test
* tests marked with tap.skip.test() are never executed * tests marked with tap.skip.test() are never executed
*/ */
public skip = { public skip = {
test: (descriptionArg: string, functionArg: ITestFunction) => { test: (descriptionArg: string, functionArg: ITestFunction<T>) => {
console.log(`skipped test: ${descriptionArg}`); console.log(`skipped test: ${descriptionArg}`);
}, },
testParallel: (descriptionArg: string, functionArg: ITestFunction) => { testParallel: (descriptionArg: string, functionArg: ITestFunction<T>) => {
console.log(`skipped test: ${descriptionArg}`); console.log(`skipped test: ${descriptionArg}`);
}, },
}; };
@ -21,26 +20,26 @@ export class Tap {
* only executes tests marked as ONLY * only executes tests marked as ONLY
*/ */
public only = { public only = {
test: (descriptionArg: string, testFunctionArg: ITestFunction) => { test: (descriptionArg: string, testFunctionArg: ITestFunction<T>) => {
this.test(descriptionArg, testFunctionArg, 'only'); this.test(descriptionArg, testFunctionArg, 'only');
}, },
}; };
private _tapPreTasks: PreTask[] = []; private _tapPreTasks: PreTask[] = [];
private _tapTests: TapTest[] = []; private _tapTests: TapTest<any>[] = [];
private _tapTestsOnly: TapTest[] = []; private _tapTestsOnly: TapTest<any>[] = [];
/** /**
* Normal test function, will run one by one * Normal test function, will run one by one
* @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<T>,
modeArg: 'normal' | 'only' | 'skip' = 'normal' modeArg: 'normal' | 'only' | 'skip' = 'normal'
) { ): TapTest<T> {
const localTest = new TapTest({ const localTest = new TapTest<T>({
description: testDescription, description: testDescription,
testFunction, testFunction,
parallel: false, parallel: false,
@ -57,19 +56,12 @@ 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
* @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 testParallel(testDescription: string, testFunction: ITestFunction) { public testParallel(testDescription: string, testFunction: ITestFunction<T>) {
this._tapTests.push( this._tapTests.push(
new TapTest({ new TapTest({
description: testDescription, description: testDescription,
@ -86,7 +78,7 @@ export class Tap {
// 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
@ -147,14 +139,14 @@ export class Tap {
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

@ -1,31 +1,39 @@
import * as plugins from './tapbundle.plugins'; import * as plugins from './tapbundle.plugins.js';
import { tapCreator } from './tapbundle.tapcreator'; import { tapCreator } from './tapbundle.tapcreator.js';
import { TapTools } from './tapbundle.classes.taptools'; import { TapTools } from './tapbundle.classes.taptools.js';
// imported interfaces // imported interfaces
import { Deferred } from '@pushrocks/smartpromise'; import { Deferred } from '@push.rocks/smartpromise';
import { HrtMeasurement } from '@pushrocks/smarttime'; import { HrtMeasurement } from '@push.rocks/smarttime';
// interfaces // interfaces
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout'; export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
export type ITestFunction = (tapTools?: TapTools) => Promise<any>; export interface ITestFunction<T> {
(tapTools?: TapTools): Promise<T>;
}
export class TapTest { export class TapTest<T = unknown> {
public description: string; public description: string;
public failureAllowed: boolean; public failureAllowed: boolean;
public hrtMeasurement: HrtMeasurement; public hrtMeasurement: HrtMeasurement;
public parallel: boolean; public parallel: boolean;
public status: TTestStatus; public status: TTestStatus;
public tapTools: TapTools; public tapTools: TapTools;
public testFunction: ITestFunction; public testFunction: ITestFunction<T>;
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<T>> = plugins.smartpromise.defer();
public testPromise: Promise<TapTest> = this.testDeferred.promise; public testPromise: Promise<TapTest<T>> = this.testDeferred.promise;
private testResultDeferred: Deferred<T> = plugins.smartpromise.defer();
public testResultPromise: Promise<T> = this.testResultDeferred.promise;
/** /**
* constructor * constructor
*/ */
constructor(optionsArg: { description: string; testFunction: ITestFunction; parallel: boolean }) { constructor(optionsArg: {
description: string;
testFunction: ITestFunction<T>;
parallel: boolean;
}) {
this.description = optionsArg.description; this.description = optionsArg.description;
this.hrtMeasurement = new HrtMeasurement(); this.hrtMeasurement = new HrtMeasurement();
this.parallel = optionsArg.parallel; this.parallel = optionsArg.parallel;
@ -42,7 +50,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 +60,14 @@ export class TapTest {
); );
this.status = 'success'; this.status = 'success';
this.testDeferred.resolve(this); this.testDeferred.resolve(this);
} catch (err) { this.testResultDeferred.resolve(testReturnValue);
} 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`
); );
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') {

View File

@ -1,5 +1,5 @@
import * as plugins from './tapbundle.plugins'; import * as plugins from './tapbundle.plugins.js';
import { TapTest } from './tapbundle.classes.taptest'; import { TapTest } from './tapbundle.classes.taptest.js';
export interface IPromiseFunc { export interface IPromiseFunc {
(): Promise<any>; (): Promise<any>;
@ -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,14 +25,18 @@ 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);
} }
public async coloredString(...args: Parameters<typeof plugins.consolecolor.coloredString>) {
return plugins.consolecolor.coloredString(...args);
}
public async timeout(timeMilliArg: number) { public async timeout(timeMilliArg: number) {
const timeout = new plugins.smartdelay.Timeout(timeMilliArg); const timeout = new plugins.smartdelay.Timeout(timeMilliArg);
timeout.makeUnrefed(); timeout.makeUnrefed();
@ -42,15 +46,11 @@ 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 {
await throwingFuncArg(); await throwingFuncArg();
} catch (err) { } catch (err: any) {
funcErr = err; funcErr = err;
} }
return funcErr; return funcErr;
@ -59,4 +59,6 @@ export class TapTools {
public defer() { public defer() {
return plugins.smartpromise.defer(); return plugins.smartpromise.defer();
} }
public smartjson = plugins.smartjson;
} }

View File

@ -1,25 +1,13 @@
import * as plugins from './tapbundle.plugins'; import * as plugins from './tapbundle.plugins.js';
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();
} }
} }

View File

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

View File

@ -1,4 +1,4 @@
import * as plugins from './tapbundle.plugins'; import * as plugins from './tapbundle.plugins.js';
export class TapCreator { export class TapCreator {
// TODO: // 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';
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();

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

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"
}