Compare commits
131 Commits
Author | SHA1 | Date | |
---|---|---|---|
22ec504b0f | |||
3d39f65ed0 | |||
7c450876f2 | |||
d7c3752dfa | |||
f53e5bcc83 | |||
d8301314a7 | |||
155b0b9f91 | |||
61c493ce72 | |||
4358e1d64d | |||
1e6296f980 | |||
0be2243ced | |||
b6c0d8013b | |||
54815c49d6 | |||
104413c37f | |||
68afa0bbdf | |||
90f618eeff | |||
4c6fb95ec9 | |||
38ddb7be1f | |||
4489be479e | |||
7cd2993be0 | |||
36d4462504 | |||
16c7ce2394 | |||
fd1a14524f | |||
c97215ed2d | |||
6dbe5098de | |||
3e9a288333 | |||
07b876ea2c | |||
28fec7a488 | |||
b99ac03942 | |||
ba6519adb5 | |||
2de0e63b3c | |||
2359841a15 | |||
0ef865ea9f | |||
a8beda7597 | |||
e029c8601f | |||
1b9f414e82 | |||
1aa4152de2 | |||
b93e962bdf | |||
0faf2ce3df | |||
831f67053e | |||
26e63372f8 | |||
929a67585f | |||
fb8d291441 | |||
5657b49a51 | |||
db39da1faf | |||
e9d6e9f9dd | |||
d8e638a07f | |||
85eb222bd9 | |||
189c0bae30 | |||
570422ae61 | |||
4ba34a4b88 | |||
ae2aabaa86 | |||
269a8c974e | |||
10ab777e7f | |||
898eed4584 | |||
7a1eae2bfb | |||
8f7167f201 | |||
6fa151f933 | |||
f846b91378 | |||
a0840ee9f4 | |||
041534f363 | |||
c89362ba8a | |||
f07879d2c1 | |||
eba3a19488 | |||
f83479a407 | |||
da711c119f | |||
6690238251 | |||
27a794b83c | |||
b3c4a58491 | |||
50c34f89ee | |||
b813453c5f | |||
9a6dc33b6b | |||
8bf99ae7ec | |||
cc708b29ae | |||
5798d3e808 | |||
37fe299a45 | |||
e24cdd9f0f | |||
ae7aaab456 | |||
bab360cc59 | |||
36dcd228fd | |||
c7d6451758 | |||
aeedf14336 | |||
14b95cfbc3 | |||
0884da7941 | |||
22df58b8bc | |||
33399126f7 | |||
d1e46fd2a7 | |||
9304e6d736 | |||
588c532d6d | |||
e3a756c775 | |||
05defe6031 | |||
f4bb17dea1 | |||
1023a94ff2 | |||
8ee456da5f | |||
45ee6eca31 | |||
1eaf1e9a77 | |||
715108b11b | |||
7b1e8f47b1 | |||
2b71ffe8c2 | |||
29ec99e63e | |||
50f1aad895 | |||
f7e95df2b9 | |||
a00536996c | |||
66f49cf8aa | |||
aa3f1eb21f | |||
d81a8006b1 | |||
5fa4c1cd85 | |||
fc609858ff | |||
19ecca0179 | |||
ff55e596cb | |||
ed8c8312c2 | |||
a6dd8de0db | |||
081347b23b | |||
f23575a8a2 | |||
b2dbc9160b | |||
1e8ab2d7a2 | |||
427878763e | |||
bdcc94e723 | |||
3ac46b2363 | |||
deae532820 | |||
99883eab82 | |||
e27e59bbeb | |||
fa54431280 | |||
aa7c49548c | |||
8d5352d000 | |||
c3ae0bc211 | |||
0381f63b65 | |||
f1441bf123 | |||
9892085140 | |||
b6d1c3c083 | |||
6e6cfbadbd |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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 @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,4 +1,20 @@
|
||||
node_modules/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
125
.gitlab-ci.yml
125
.gitlab-ci.yml
@ -1,125 +0,0 @@
|
||||
# gitzone standard
|
||||
image: 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:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
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: {}
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -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", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
72
README.md
72
README.md
@ -1,72 +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
|
||||
[](https://gitlab.com/pushrocks/tapbundle/commits/master)
|
||||
[](https://gitlab.com/pushrocks/tapbundle/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/tapbundle)
|
||||
[](https://snyk.io/test/npm/@pushrocks/tapbundle)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](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)
|
||||
```
|
||||
|
||||
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.html)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
187
changelog.md
Normal file
187
changelog.md
Normal file
@ -0,0 +1,187 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-09-18 - 5.1.3 - fix(ts_node/classes.tapnodetools.ts)
|
||||
Refactored methods and improved type annotations in TapNodeTools class.
|
||||
|
||||
- Refactored `runCommand` method to include proper type annotations.
|
||||
- Enhanced `createHttpsCert` method with proper type annotations and key generation logic.
|
||||
- Introduced `generateSelfSignedCert` method for better code organization and readability.
|
||||
|
||||
## 2024-09-18 - 5.1.2 - fix(TapNodeTools)
|
||||
Default parameter added to createHttpsCert method
|
||||
|
||||
- Updated createHttpsCert method to provide a default value for the parameter commonName.
|
||||
|
||||
## 2024-09-18 - 5.1.1 - fix(ts_node)
|
||||
Fixed createHttpsCert interface
|
||||
|
||||
- Removed unnecessary keyFile and certFile parameters from createHttpsCert method.
|
||||
|
||||
## 2024-09-18 - 5.1.0 - feat(ts_node)
|
||||
Add support for HTTPS certificate creation
|
||||
|
||||
- Added TapNodeTools class with methods to run commands and create HTTPS certificates
|
||||
- Exported necessary plugins including crypto and fs for node
|
||||
- Updated test cases to include tests for HTTPS certificate creation
|
||||
|
||||
## 2024-09-17 - 5.0.25 - fix(core)
|
||||
Fix typos in package.json, update dependencies and update workflow.
|
||||
|
||||
- Fixed references to deprecated package names in workflows and package.json.
|
||||
- Updated versions of @push.rocks dependencies to latest stable.
|
||||
- Corrected scripts in package.json to reflect new build and documentation commands.
|
||||
- Fixed async startup in browser tests.
|
||||
|
||||
## 2024-08-17 - 5.0.24 - fix(dependencies)
|
||||
Update dependencies
|
||||
|
||||
- Updated @push.rocks/smartexpect from ^1.0.21 to ^1.1.0
|
||||
- Updated @push.rocks/smartjson from ^5.0.16 to ^5.0.20
|
||||
- Updated @push.rocks/smartpromise from ^4.0.2 to ^4.0.4
|
||||
- Updated @push.rocks/smarttime from ^4.0.6 to ^4.0.8
|
||||
- Updated @types/node from ^20.11.30 to ^22.4.0
|
||||
|
||||
## 2024-05-29 - 5.0.23 - General Update
|
||||
update description
|
||||
|
||||
## 2024-04-14 to 2024-04-15 - 5.0.22 - Configuration Updates and Bug Fixes
|
||||
Multiple updates in tsconfig and npmextra.json
|
||||
|
||||
- fix(core): update
|
||||
- update tsconfig
|
||||
- update npmextra.json: githost
|
||||
|
||||
## 2024-03-19 - 5.0.21 to 5.0.17 - Bug Fix Release
|
||||
Multiple core fixes and updates without specific feature changes
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2024-03-13 - 5.0.16 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2023-08-12 - 5.0.15 to 5.0.13 - Bug Fix Release
|
||||
Multiple core fixes and updates without specific feature changes
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2023-07-13 - 5.0.12 to 5.0.10 - Bug Fix Release
|
||||
Multiple core fixes and updates without specific feature changes
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2023-06-22 - 5.0.9 to 5.0.7 - Bug Fix Release
|
||||
Multiple core fixes and updates without specific feature changes
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2022-07-24 - 5.0.6 to 5.0.3 - Bug Fix Release
|
||||
Multiple core fixes and updates without specific feature changes
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2022-03-14 - 5.0.2 to 5.0.0 - Initial Release of Version 5.x.x
|
||||
Multiple bug fixes and updates.
|
||||
- fix(core): update
|
||||
|
||||
## 2022-03-14 - 4.0.9 to 4.0.8 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2022-02-28 - 4.0.7 to 4.0.4 - Bug Fix Release
|
||||
Multiple core fixes and updates without specific feature changes
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2022-02-02 - 4.0.3 to 4.0.1 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2022-01-21 - 4.0.0 - Major Release
|
||||
Version 4.x.x Major improvements and core fixes
|
||||
|
||||
## 2021-12-10 - 3.2.15 - Breaking Change
|
||||
BREAKING CHANGE(core): switch to @pushrocks/smartexpect
|
||||
|
||||
## 2021-12-10 - 3.2.14 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2021-02-13 - 3.2.13 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2021-01-26 - 3.2.12 to 3.2.11 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2020-07-11 - 3.2.10 to 3.2.8 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2020-07-08 - 3.2.7 to 3.2.4 - Bug Fix Release
|
||||
Multiple core fixes and updates without specific feature changes
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2020-07-08 - 3.2.5 - Documentation Update
|
||||
- update readme
|
||||
|
||||
## 2019-11-16 - 3.1.0 - New Feature
|
||||
- feat(pretask): introduce new pretask functionality for setting up testing environment
|
||||
|
||||
## 2019-11-16 - 3.0.14 - New Feature
|
||||
- feat(tools): can now ensure certain directories
|
||||
|
||||
## 2019-08-23 - 3.0.13 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2019-08-22 - 3.0.12 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2019-06-19 - 3.0.11 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2019-04-10 - 3.0.9 to 3.0.8 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2018-09-03 - 3.0.7 - Bug Fix Release
|
||||
- fix(core): update
|
||||
|
||||
## 2018-09-02 - 3.0.6 - Dependency Update
|
||||
- fix(dependencies): update to latest versions
|
||||
|
||||
## 2018-08-08 - 3.0.5 - New Feature
|
||||
- fix(core): add tap.only option
|
||||
|
||||
## 2018-08-08 - 3.0.4 - Dependency Update
|
||||
- fix(dependencies): update
|
||||
|
||||
## 2018-08-08 - 3.0.3 - Dependency Update
|
||||
- fix(dependencies): use @git.zone/tsbuild instead of npmts
|
||||
|
||||
## 2018-07-18 - 3.0.2 - Dependency Update
|
||||
- fix(dependencies): now typings-global free
|
||||
|
||||
## 2018-07-13 - 3.0.1 - Dependency Update
|
||||
- fix(dependencies): update
|
||||
|
||||
## 2018-07-13 - 3.0.0 - Package Update
|
||||
- fix(package): npm access level
|
||||
|
||||
## 2018-06-28 - 2.0.2 - Breaking Change
|
||||
BREAKING CHANGE(package): change scope
|
||||
|
||||
## 2018-06-28 - 2.0.1 - Security Update
|
||||
- fix(security): add snyk file
|
||||
|
||||
## 2018-02-27 - 2.0.0 - Compatibility Update
|
||||
- fix(core): fix node 10.x.x compatibility
|
||||
|
||||
## 2017-10-11 - 1.1.8 - Update
|
||||
- update to use latest smartchai
|
||||
|
||||
## 2017-10-11 - 1.1.7 - Update
|
||||
- update ci
|
||||
|
||||
## 2017-10-10 - 1.1.6 - Documentation Update
|
||||
- add new docs
|
||||
|
||||
## 2017-10-09 - 1.1.5 - Feature Update
|
||||
- now has working leak detection
|
||||
|
||||
## 2017-03-26 - 1.0.9 - Standards Update
|
||||
- update to latest standards
|
@ -1,87 +0,0 @@
|
||||
# Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
|
||||
# Project information
|
||||
site_name: tapbundle | docs
|
||||
site_description: a taprunner
|
||||
site_author: Lossless GmbH
|
||||
site_url: https://push.rocks
|
||||
|
||||
# Repository
|
||||
repo_name: pushrocks/tapbundle
|
||||
repo_url: https://gitlab.com/pushrocks/tapbundle
|
||||
|
||||
# Copyright
|
||||
copyright: 'Copyright © 2014 Lossless GmbH'
|
||||
|
||||
# Theme directory
|
||||
theme: material
|
||||
theme_dir: 'theme'
|
||||
|
||||
# Options
|
||||
extra:
|
||||
feature:
|
||||
tabs: false
|
||||
palette:
|
||||
primary: indigo
|
||||
accent: indigo
|
||||
social:
|
||||
- type: globe
|
||||
link: http://lossless.com
|
||||
- type: github-alt
|
||||
link: https://github.com/philkunz
|
||||
- type: twitter
|
||||
link: https://twitter.com/philkunzcom
|
||||
- type: linkedin
|
||||
link: https://linkedin.com/in/philippkunz
|
||||
|
||||
# Extensions
|
||||
markdown_extensions:
|
||||
- markdown.extensions.admonition
|
||||
- markdown.extensions.codehilite(guess_lang=false, linenums=true)
|
||||
- markdown.extensions.def_list
|
||||
- markdown.extensions.footnotes
|
||||
- markdown.extensions.meta
|
||||
- markdown.extensions.toc(permalink=true)
|
||||
- pymdownx.arithmatex
|
||||
- pymdownx.betterem(smart_enable=all)
|
||||
- pymdownx.caret
|
||||
- pymdownx.critic
|
||||
- pymdownx.details
|
||||
- pymdownx.emoji:
|
||||
emoji_generator: !!python/name:pymdownx.emoji.to_svg
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.magiclink
|
||||
- pymdownx.mark
|
||||
- pymdownx.smartsymbols
|
||||
- pymdownx.superfences
|
||||
- pymdownx.tasklist(custom_checkbox=true)
|
||||
- pymdownx.tilde
|
||||
|
||||
# Page tree
|
||||
pages:
|
||||
- Repo Readme: index.md
|
||||
- Get Started: getstarted.md
|
||||
- License: license.md
|
||||
|
||||
# Google Analytics
|
||||
google_analytics:
|
||||
- !!python/object/apply:os.getenv ["GOOGLE_ANALYTICS_KEY"]
|
||||
- auto
|
56
docs/theme/partials/footer.html
vendored
56
docs/theme/partials/footer.html
vendored
@ -1,56 +0,0 @@
|
||||
{% import "partials/language.html" as lang %}
|
||||
<footer class="md-footer">
|
||||
{% if page.previous_page or page.next_page %}
|
||||
<div class="md-footer-nav">
|
||||
<nav class="md-footer-nav__inner md-grid">
|
||||
{% if page.previous_page %}
|
||||
<a href="{{ page.previous_page.url }}" title="{{ page.previous_page.title }}" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
|
||||
<div class="md-flex__cell md-flex__cell--shrink">
|
||||
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
|
||||
</div>
|
||||
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||
<span class="md-flex__ellipsis">
|
||||
<span class="md-footer-nav__direction">
|
||||
{{ lang.t("footer.previous") }}
|
||||
</span>
|
||||
{{ page.previous_page.title }}
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if page.next_page %}
|
||||
<a href="{{ page.next_page.url }}" title="{{ page.next_page.title }}" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
|
||||
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
|
||||
<span class="md-flex__ellipsis">
|
||||
<span class="md-footer-nav__direction">
|
||||
{{ lang.t("footer.next") }}
|
||||
</span>
|
||||
{{ page.next_page.title }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="md-flex__cell md-flex__cell--shrink">
|
||||
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="md-footer-meta md-typeset">
|
||||
<div class="md-footer-meta__inner md-grid">
|
||||
<div class="md-footer-copyright">
|
||||
{% if config.copyright %}
|
||||
<div class="md-footer-copyright__highlight">
|
||||
{{ config.copyright }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="https://lossless.gmbh" title="push.rocks">Impressum</a>
|
||||
|
|
||||
<a href="https://lossless.com" title="Lossless GmbH">Company Website</a>
|
||||
</div>
|
||||
{% block social %}
|
||||
{% include "partials/social.html" %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
@ -9,13 +9,31 @@
|
||||
}
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "tapbundle",
|
||||
"shortDescription": "tap bundled for tapbuffer",
|
||||
"npmPackagename": "@pushrocks/tapbundle",
|
||||
"license": "MIT"
|
||||
"description": "A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.",
|
||||
"npmPackagename": "@push.rocks/tapbundle",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"testing",
|
||||
"automation",
|
||||
"TAP",
|
||||
"test anything protocol",
|
||||
"unit testing",
|
||||
"integration testing",
|
||||
"JavaScript",
|
||||
"TypeScript",
|
||||
"test runner",
|
||||
"test framework",
|
||||
"web helpers",
|
||||
"test utilities"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
1690
package-lock.json
generated
1690
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
77
package.json
77
package.json
@ -1,38 +1,73 @@
|
||||
{
|
||||
"name": "@pushrocks/tapbundle",
|
||||
"name": "@push.rocks/tapbundle",
|
||||
"private": false,
|
||||
"version": "3.0.8",
|
||||
"description": "tap bundled for tapbuffer",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"version": "5.1.3",
|
||||
"description": "A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.",
|
||||
"exports": {
|
||||
".": "./dist_ts/index.js",
|
||||
"./node": "./dist_ts_node/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
"build": "(tsbuild tsfolders --web --allowimplicitany --skiplibcheck)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/tapbundle.git"
|
||||
"url": "https://code.foss.global/push.rocks/tapbundle.git"
|
||||
},
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/tapbundle/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
||||
"homepage": "https://code.foss.global/push.rocks/tapbundle",
|
||||
"dependencies": {
|
||||
"@pushrocks/early": "^3.0.3",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"leakage": "^0.4.0",
|
||||
"smartchai": "^2.0.1"
|
||||
"@open-wc/testing": "^4.0.0",
|
||||
"@push.rocks/consolecolor": "^2.0.2",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartenv": "^5.0.12",
|
||||
"@push.rocks/smartexpect": "^1.2.1",
|
||||
"@push.rocks/smartjson": "^5.0.20",
|
||||
"@push.rocks/smartpromise": "^4.0.4",
|
||||
"@push.rocks/smartshell": "^3.0.6",
|
||||
"@push.rocks/smarttime": "^4.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.8",
|
||||
"@gitzone/tsrun": "^1.2.5",
|
||||
"@gitzone/tstest": "^1.0.20",
|
||||
"@types/node": "^11.13.2",
|
||||
"randomstring": "^1.1.5",
|
||||
"tslint": "^5.15.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
}
|
||||
"@git.zone/tsbuild": "^2.1.66",
|
||||
"@git.zone/tsrun": "^1.2.43",
|
||||
"@git.zone/tstest": "^1.0.77",
|
||||
"@types/node": "^22.5.5",
|
||||
"randomstring": "^1.3.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"keywords": [
|
||||
"testing",
|
||||
"automation",
|
||||
"TAP",
|
||||
"test anything protocol",
|
||||
"unit testing",
|
||||
"integration testing",
|
||||
"JavaScript",
|
||||
"TypeScript",
|
||||
"test runner",
|
||||
"test framework",
|
||||
"web helpers",
|
||||
"test utilities"
|
||||
]
|
||||
}
|
||||
|
6665
pnpm-lock.yaml
generated
Normal file
6665
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
138
readme.md
Normal file
138
readme.md
Normal file
@ -0,0 +1,138 @@
|
||||
# @push.rocks/tapbundle
|
||||
tap bundled for tapbuffer
|
||||
|
||||
## Install
|
||||
Install the package by running the following command in your terminal:
|
||||
|
||||
```bash
|
||||
npm install @push.rocks/tapbundle --save-dev
|
||||
```
|
||||
|
||||
This will add `@push.rocks/tapbundle` to your project's `devDependencies`.
|
||||
|
||||
## Usage
|
||||
The `@push.rocks/tapbundle` package is a tap-compatible testing framework written in TypeScript, intended for use with tapbuffer. It includes a range of useful features enabling easy setup and execution of tests, assertion handling through `expect` and `expectAsync`, as well as auxiliary tools for delay and colored console output.
|
||||
|
||||
### Getting Started
|
||||
First, ensure your project is set up with Typescript and supports ESM syntax. You can then import `tap`, `expect`, and `expectAsync` from `@push.rocks/tapbundle` to start defining your tests.
|
||||
|
||||
```typescript
|
||||
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
||||
```
|
||||
|
||||
Here is a simple test example:
|
||||
|
||||
```typescript
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
|
||||
tap.test('should succeed on true assertion', async () => {
|
||||
return expect(true).toBeTrue();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
```
|
||||
|
||||
### Defining Tests
|
||||
You can define tests with descriptions and async functions. The `tap` instance manages test execution, supports test skipping, and managing exclusive tests with the `.only` modifier.
|
||||
|
||||
```typescript
|
||||
const myTest = tap.test('expect true to be true', async () => {
|
||||
expect(true).toBeTrue();
|
||||
});
|
||||
|
||||
const skippedTest = tap.skip.test('this test is skipped', async () => {
|
||||
// This will not be executed
|
||||
});
|
||||
|
||||
tap.only.test('only this test will run', async () => {
|
||||
expect('TapBundle').toContainString('Tap');
|
||||
});
|
||||
|
||||
tap.start();
|
||||
```
|
||||
|
||||
### Using `expect` and `expectAsync`
|
||||
The package provides `expect` and `expectAsync` for assertions:
|
||||
|
||||
```typescript
|
||||
await expectAsync(Promise.resolve(true)).toBeResolved();
|
||||
expect(5).toBeGreaterThan(2);
|
||||
```
|
||||
|
||||
### Handling Asynchronous Operations
|
||||
`tapbundle` facilitates working with async operations in tests. You can introduce delays or set timeouts:
|
||||
|
||||
```typescript
|
||||
tap.test('async operation with delay', async (tools) => {
|
||||
await tools.delayFor(2000); // Wait for 2000 milliseconds
|
||||
expect(true).toBeTrue();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
```
|
||||
|
||||
### Advanced Usage
|
||||
#### Pre Tasks
|
||||
You can define tasks to run before test execution begins:
|
||||
|
||||
```typescript
|
||||
tap.preTask('setup database', async () => {
|
||||
// Perform setup here
|
||||
});
|
||||
|
||||
tap.test('test database connection', async () => {
|
||||
// Test the setup
|
||||
});
|
||||
|
||||
tap.start();
|
||||
```
|
||||
|
||||
#### Accessing Test Metadata
|
||||
Each test returns a `TapTest` instance, from which you can access metadata and manipulate test behavior:
|
||||
|
||||
```typescript
|
||||
const test = tap.test('metadata example', async (tools) => {
|
||||
tools.allowFailure();
|
||||
expect(true).toBeTrue();
|
||||
});
|
||||
|
||||
tap.start().then(() => {
|
||||
console.log(`Test duration: ${test.hrtMeasurement.milliSeconds}ms`);
|
||||
});
|
||||
```
|
||||
|
||||
### Running Tests
|
||||
Tests are executed by calling `tap.start()`. This method runs all defined tests in sequence and respects `.skip` and `.only` modifiers.
|
||||
|
||||
### Debugging and Output
|
||||
`@push.rocks/tapbundle` supports colored console output via `consolecolor` to help with debugging and test result readability:
|
||||
|
||||
```typescript
|
||||
tap.test('colored output', async (tools) => {
|
||||
const coloredString = await tools.coloredString('Hello, world!', 'green');
|
||||
console.log(coloredString);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
```
|
||||
|
||||
This detailed guide covers the most important aspects of using `@push.rocks/tapbundle` for testing in your TypeScript projects. Explore the included functions and tools to fully leverage this comprehensive testing framework.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
48
test/test.browser.nonci.ts
Normal file
48
test/test.browser.nonci.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { tap, expect, webhelpers } from '../ts/index.js';
|
||||
|
||||
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).toBeTrue();
|
||||
});
|
||||
|
||||
const test2 = tap.test('my second test', async (tools) => {
|
||||
await tools.delayFor(50);
|
||||
});
|
||||
|
||||
const test3 = tap.test(
|
||||
'my third test -> test2 should take longer than test1 and endure at least 1000ms',
|
||||
async () => {
|
||||
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).toBeTrue();
|
||||
});
|
||||
|
||||
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) => {
|
||||
tools.allowFailure();
|
||||
tools.timeout(1000);
|
||||
await tools.delayFor(100);
|
||||
});
|
||||
|
||||
await tap.start();
|
@ -1,23 +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));
|
||||
});
|
||||
});
|
||||
if (!process.version.startsWith('v11')) {
|
||||
expect(err).to.be.instanceof(Error);
|
||||
}
|
||||
});
|
||||
|
||||
tap.start();
|
18
test/test.node.ts
Normal file
18
test/test.node.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { tap, expect } from '../ts/index.js';
|
||||
|
||||
import { tapNodeTools } from '../ts_node/index.js';
|
||||
|
||||
tap.test('should execure a command', async () => {
|
||||
const result = await tapNodeTools.runCommand('ls -la');
|
||||
expect(result.exitCode).toEqual(0);
|
||||
});
|
||||
|
||||
tap.test('should create a https cert', async () => {
|
||||
const { key, cert } = await tapNodeTools.createHttpsCert('localhost');
|
||||
console.log(key);
|
||||
console.log(cert);
|
||||
expect(key).toInclude('-----BEGIN PRIVATE KEY-----');
|
||||
expect(cert).toInclude('-----BEGIN CERTIFICATE-----');
|
||||
});
|
||||
|
||||
tap.start();
|
@ -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 do something', async () => {
|
||||
console.log('test1');
|
||||
});
|
||||
tap.start();
|
||||
});
|
||||
tap.test('should run a test', async () => {});
|
||||
|
||||
tapwrap.run();
|
||||
tap.start();
|
||||
|
35
test/test.ts
35
test/test.ts
@ -1,36 +1,49 @@
|
||||
import { tap, expect } from '../ts/index';
|
||||
import { tap, expect } from '../ts/index.js';
|
||||
|
||||
const test1 = tap.test('my first test -> expect true to be true', async () => {
|
||||
return expect(true).to.be.true;
|
||||
tap.preTask('hi there', async () => {
|
||||
console.log('this is a pretask');
|
||||
});
|
||||
|
||||
const test2 = tap.test('my second test', async tools => {
|
||||
const test1 = tap.test('my first test -> expect true to be true', async () => {
|
||||
return expect(true).toBeTrue();
|
||||
});
|
||||
|
||||
const test2 = tap.test('my second test', async (tools) => {
|
||||
await tools.delayFor(1000);
|
||||
});
|
||||
|
||||
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 > 1000).to.be.true;
|
||||
expect(
|
||||
(await test1.testPromise).hrtMeasurement.milliSeconds <
|
||||
(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();
|
||||
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);
|
||||
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);
|
||||
});
|
||||
|
||||
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();
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/tapbundle',
|
||||
version: '5.1.3',
|
||||
description: 'A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.'
|
||||
}
|
@ -1,2 +1,7 @@
|
||||
export { expect } from 'smartchai';
|
||||
export { tap } from './tapbundle.classes.tap';
|
||||
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 };
|
||||
|
21
ts/tapbundle.classes.pretask.ts
Normal file
21
ts/tapbundle.classes.pretask.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import * as plugins from './tapbundle.plugins.js';
|
||||
import { TapTools } from './tapbundle.classes.taptools.js';
|
||||
|
||||
export interface IPreTaskFunction {
|
||||
(tapTools?: TapTools): Promise<any>;
|
||||
}
|
||||
|
||||
export class PreTask {
|
||||
public description: string;
|
||||
public preTaskFunction: IPreTaskFunction;
|
||||
|
||||
constructor(descriptionArg: string, preTaskFunctionArg: IPreTaskFunction) {
|
||||
this.description = descriptionArg;
|
||||
this.preTaskFunction = preTaskFunctionArg;
|
||||
}
|
||||
|
||||
public async run() {
|
||||
console.log(`::__PRETASK: ${this.description}`);
|
||||
await this.preTaskFunction(new TapTools(null));
|
||||
}
|
||||
}
|
@ -1,47 +1,48 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
import * as plugins from './tapbundle.plugins.js';
|
||||
|
||||
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
||||
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
|
||||
export class Tap {
|
||||
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
|
||||
*/
|
||||
skip = {
|
||||
test: (descriptionArg: string, functionArg: ITestFunction) => {
|
||||
public skip = {
|
||||
test: (descriptionArg: string, functionArg: ITestFunction<T>) => {
|
||||
console.log(`skipped test: ${descriptionArg}`);
|
||||
},
|
||||
testParallel: (descriptionArg: string, functionArg: ITestFunction) => {
|
||||
testParallel: (descriptionArg: string, functionArg: ITestFunction<T>) => {
|
||||
console.log(`skipped test: ${descriptionArg}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* only executes tests marked as ONLY
|
||||
*/
|
||||
only = {
|
||||
test: (descriptionArg: string, testFunctionArg: ITestFunction) => {
|
||||
public only = {
|
||||
test: (descriptionArg: string, testFunctionArg: ITestFunction<T>) => {
|
||||
this.test(descriptionArg, testFunctionArg, 'only');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
private _tapTests: TapTest[] = [];
|
||||
private _tapTestsOnly: TapTest[] = [];
|
||||
private _tapPreTasks: PreTask[] = [];
|
||||
private _tapTests: TapTest<any>[] = [];
|
||||
private _tapTestsOnly: TapTest<any>[] = [];
|
||||
|
||||
/**
|
||||
* Normal test function, will run one by one
|
||||
* @param testDescription - A description of what the test does
|
||||
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
||||
*/
|
||||
async test(
|
||||
public test(
|
||||
testDescription: string,
|
||||
testFunction: ITestFunction,
|
||||
testFunction: ITestFunction<T>,
|
||||
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
||||
) {
|
||||
let localTest = new TapTest({
|
||||
): TapTest<T> {
|
||||
const localTest = new TapTest<T>({
|
||||
description: testDescription,
|
||||
testFunction: testFunction,
|
||||
parallel: false
|
||||
testFunction,
|
||||
parallel: false,
|
||||
});
|
||||
if (modeArg === 'normal') {
|
||||
this._tapTests.push(localTest);
|
||||
@ -51,11 +52,8 @@ export class Tap {
|
||||
return localTest;
|
||||
}
|
||||
|
||||
/**
|
||||
* wraps function
|
||||
*/
|
||||
wrap(functionArg: ITapWrapFunction) {
|
||||
return new TapWrap(functionArg);
|
||||
public preTask(descriptionArg: string, functionArg: IPreTaskFunction) {
|
||||
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,12 +61,12 @@ export class Tap {
|
||||
* @param testDescription - A description of what the test does
|
||||
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
||||
*/
|
||||
testParallel(testDescription: string, testFunction: ITestFunction) {
|
||||
public testParallel(testDescription: string, testFunction: ITestFunction<T>) {
|
||||
this._tapTests.push(
|
||||
new TapTest({
|
||||
description: testDescription,
|
||||
testFunction: testFunction,
|
||||
parallel: true
|
||||
testFunction,
|
||||
parallel: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -76,12 +74,20 @@ export class Tap {
|
||||
/**
|
||||
* starts the test evaluation
|
||||
*/
|
||||
async start(optionsArg?: { throwOnError: boolean }) {
|
||||
let promiseArray: Promise<any>[] = [];
|
||||
public async start(optionsArg?: { throwOnError: boolean }) {
|
||||
// lets set the tapbundle promise
|
||||
const smartenvInstance = new plugins.smartenv.Smartenv();
|
||||
smartenvInstance.isBrowser
|
||||
? ((globalThis as any).tapbundleDeferred = plugins.smartpromise.defer())
|
||||
: null;
|
||||
|
||||
// lets continue with running the tests
|
||||
const promiseArray: Array<Promise<any>> = [];
|
||||
|
||||
// safeguard against empty test array
|
||||
if (this._tapTests.length === 0) {
|
||||
console.log('no tests specified. Ending here!');
|
||||
// TODO: throw proper error
|
||||
return;
|
||||
}
|
||||
|
||||
@ -93,10 +99,15 @@ export class Tap {
|
||||
concerningTests = this._tapTests;
|
||||
}
|
||||
|
||||
// lets run the pretasks
|
||||
for (const preTask of this._tapPreTasks) {
|
||||
await preTask.run();
|
||||
}
|
||||
|
||||
console.log(`1..${concerningTests.length}`);
|
||||
for (let testKey = 0; testKey < concerningTests.length; testKey++) {
|
||||
let currentTest = concerningTests[testKey];
|
||||
let testPromise = currentTest.run(testKey);
|
||||
const currentTest = concerningTests[testKey];
|
||||
const testPromise = currentTest.run(testKey);
|
||||
if (currentTest.parallel) {
|
||||
promiseArray.push(testPromise);
|
||||
} else {
|
||||
@ -106,10 +117,10 @@ export class Tap {
|
||||
await Promise.all(promiseArray);
|
||||
|
||||
// when tests have been run and all promises are fullfilled
|
||||
let failReasons: string[] = [];
|
||||
let executionNotes: string[] = [];
|
||||
const failReasons: string[] = [];
|
||||
const executionNotes: string[] = [];
|
||||
// collect failed tests
|
||||
for (let tapTest of concerningTests) {
|
||||
for (const tapTest of concerningTests) {
|
||||
if (tapTest.status !== 'success') {
|
||||
failReasons.push(
|
||||
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
||||
@ -120,19 +131,33 @@ export class Tap {
|
||||
}
|
||||
|
||||
// render fail Reasons
|
||||
for (let failReason of failReasons) {
|
||||
for (const failReason of failReasons) {
|
||||
console.log(failReason);
|
||||
}
|
||||
|
||||
if (optionsArg && optionsArg.throwOnError && failReasons.length > 0) {
|
||||
process.exit(1);
|
||||
if (!smartenvInstance.isBrowser) process.exit(1);
|
||||
}
|
||||
if (smartenvInstance.isBrowser) {
|
||||
(globalThis as any).tapbundleDeferred.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
public async stopForcefully(codeArg = 0, directArg = false) {
|
||||
console.log(`tap stopping forcefully! Code: ${codeArg} / Direct: ${directArg}`);
|
||||
if (directArg) {
|
||||
process.exit(codeArg);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
process.exit(codeArg);
|
||||
}, 10)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* handle errors
|
||||
*/
|
||||
threw(err) {
|
||||
public threw(err: Error) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,39 @@
|
||||
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 { HrtMeasurement } from '@pushrocks/early';
|
||||
import { Deferred } from '@pushrocks/smartpromise';
|
||||
import { Deferred } from '@push.rocks/smartpromise';
|
||||
import { HrtMeasurement } from '@push.rocks/smarttime';
|
||||
|
||||
// interfaces
|
||||
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
|
||||
|
||||
export interface ITestFunction {
|
||||
(tapTools?: TapTools): Promise<any>;
|
||||
export interface ITestFunction<T> {
|
||||
(tapTools?: TapTools): Promise<T>;
|
||||
}
|
||||
|
||||
export class TapTest {
|
||||
description: string;
|
||||
failureAllowed: boolean;
|
||||
hrtMeasurement: HrtMeasurement;
|
||||
parallel: boolean;
|
||||
status: TTestStatus;
|
||||
tapTools: TapTools;
|
||||
testFunction: ITestFunction;
|
||||
testKey: number; // the testKey the position in the test qeue. Set upon calling .run()
|
||||
testDeferred: Deferred<TapTest> = plugins.smartpromise.defer();
|
||||
testPromise: Promise<TapTest> = this.testDeferred.promise;
|
||||
export class TapTest<T = unknown> {
|
||||
public description: string;
|
||||
public failureAllowed: boolean;
|
||||
public hrtMeasurement: HrtMeasurement;
|
||||
public parallel: boolean;
|
||||
public status: TTestStatus;
|
||||
public tapTools: TapTools;
|
||||
public testFunction: ITestFunction<T>;
|
||||
public testKey: number; // the testKey the position in the test qeue. Set upon calling .run()
|
||||
private testDeferred: Deferred<TapTest<T>> = plugins.smartpromise.defer();
|
||||
public testPromise: Promise<TapTest<T>> = this.testDeferred.promise;
|
||||
private testResultDeferred: Deferred<T> = plugins.smartpromise.defer();
|
||||
public testResultPromise: Promise<T> = this.testResultDeferred.promise;
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
constructor(optionsArg: { description: string; testFunction: ITestFunction; parallel: boolean }) {
|
||||
constructor(optionsArg: {
|
||||
description: string;
|
||||
testFunction: ITestFunction<T>;
|
||||
parallel: boolean;
|
||||
}) {
|
||||
this.description = optionsArg.description;
|
||||
this.hrtMeasurement = new HrtMeasurement();
|
||||
this.parallel = optionsArg.parallel;
|
||||
@ -39,12 +45,12 @@ export class TapTest {
|
||||
/**
|
||||
* run the test
|
||||
*/
|
||||
async run(testKeyArg: number) {
|
||||
public async run(testKeyArg: number) {
|
||||
this.hrtMeasurement.start();
|
||||
this.testKey = testKeyArg;
|
||||
let testNumber = testKeyArg + 1;
|
||||
const testNumber = testKeyArg + 1;
|
||||
try {
|
||||
await this.testFunction(this.tapTools);
|
||||
const testReturnValue = await this.testFunction(this.tapTools);
|
||||
if (this.status === 'timeout') {
|
||||
throw new Error('Test succeeded, but timed out...');
|
||||
}
|
||||
@ -54,12 +60,14 @@ export class TapTest {
|
||||
);
|
||||
this.status = 'success';
|
||||
this.testDeferred.resolve(this);
|
||||
} catch (err) {
|
||||
this.testResultDeferred.resolve(testReturnValue);
|
||||
} catch (err: any) {
|
||||
this.hrtMeasurement.stop();
|
||||
console.log(
|
||||
`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`
|
||||
);
|
||||
this.testDeferred.resolve(this);
|
||||
this.testResultDeferred.resolve(err);
|
||||
|
||||
// if the test has already succeeded before
|
||||
if (this.status === 'success') {
|
||||
|
@ -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,14 +25,18 @@ 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);
|
||||
}
|
||||
|
||||
public async coloredString(...args: Parameters<typeof plugins.consolecolor.coloredString>) {
|
||||
return plugins.consolecolor.coloredString(...args);
|
||||
}
|
||||
|
||||
public async timeout(timeMilliArg: number) {
|
||||
const timeout = new plugins.smartdelay.Timeout(timeMilliArg);
|
||||
timeout.makeUnrefed();
|
||||
@ -42,25 +46,19 @@ export class TapTools {
|
||||
}
|
||||
}
|
||||
|
||||
public async checkIterationLeak(iterationfuncArg: IPromiseFunc) {
|
||||
if (process.version.startsWith('v11')) {
|
||||
console.log('iteration leakage checks disabled for now on version 11 due to low performance');
|
||||
} else {
|
||||
await plugins.leakage.iterate.async(iterationfuncArg);
|
||||
}
|
||||
}
|
||||
|
||||
public async returnError(throwingFuncArg: IPromiseFunc) {
|
||||
let funcErr: Error;
|
||||
try {
|
||||
await throwingFuncArg();
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
funcErr = err;
|
||||
}
|
||||
return funcErr;
|
||||
}
|
||||
|
||||
public defer () {
|
||||
public defer() {
|
||||
return plugins.smartpromise.defer();
|
||||
}
|
||||
|
||||
public smartjson = plugins.smartjson;
|
||||
}
|
||||
|
@ -1,24 +1,13 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
import * as plugins from './tapbundle.plugins.js';
|
||||
|
||||
export interface ITapWrapFunction {
|
||||
(): Promise<any>;
|
||||
export interface ITapWrapOptions {
|
||||
before: () => Promise<any>;
|
||||
after: () => {};
|
||||
}
|
||||
|
||||
export class TapWrap {
|
||||
wrapFunction: ITapWrapFunction;
|
||||
|
||||
/**
|
||||
* the constructor
|
||||
*/
|
||||
constructor(wrapFunctionArg: ITapWrapFunction) {
|
||||
// nothing here
|
||||
this.wrapFunction = wrapFunctionArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* run the wrapFunction
|
||||
*/
|
||||
async run() {
|
||||
await this.wrapFunction();
|
||||
public options: ITapWrapOptions;
|
||||
constructor(optionsArg: ITapWrapOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
import * as early from '@pushrocks/early';
|
||||
import * as leakage from 'leakage';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
// pushrocks
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
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 { early, smartdelay, smartpromise, leakage };
|
||||
export { consolecolor, smartdelay, smartenv, smartexpect, smartjson, smartpromise };
|
||||
|
@ -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
25
ts/webhelpers.ts
Normal 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();
|
65
ts_node/classes.tapnodetools.ts
Normal file
65
ts_node/classes.tapnodetools.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import { createSign } from 'crypto';
|
||||
|
||||
class TapNodeTools {
|
||||
private smartshellInstance: plugins.smartshell.Smartshell;
|
||||
|
||||
constructor() {}
|
||||
|
||||
public async runCommand(commandArg: string): Promise<any> {
|
||||
if (!this.smartshellInstance) {
|
||||
this.smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
}
|
||||
const result = await this.smartshellInstance.exec(commandArg);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async createHttpsCert(
|
||||
commonName: string = 'localhost'
|
||||
): Promise<{ key: string; cert: string }> {
|
||||
// Generate RSA key pair
|
||||
const { publicKey, privateKey } = plugins.crypto.generateKeyPairSync('rsa', {
|
||||
modulusLength: 2048,
|
||||
publicExponent: 65537,
|
||||
});
|
||||
|
||||
// Create a self-signed certificate
|
||||
const cert = this.generateSelfSignedCert(publicKey, privateKey, commonName);
|
||||
|
||||
// Export the private key and return the cert and key
|
||||
const keyContent = privateKey.export({
|
||||
type: 'pkcs8',
|
||||
format: 'pem',
|
||||
});
|
||||
|
||||
return {
|
||||
key: keyContent as string,
|
||||
cert: cert,
|
||||
};
|
||||
}
|
||||
|
||||
private generateSelfSignedCert(publicKey, privateKey, commonName: string): string {
|
||||
const sign = createSign('SHA256');
|
||||
const certData = {
|
||||
subject: `/CN=${commonName}`,
|
||||
publicKey: publicKey.export({ type: 'spki', format: 'pem' }),
|
||||
};
|
||||
|
||||
sign.update(JSON.stringify(certData));
|
||||
sign.end();
|
||||
|
||||
const signature = sign.sign(privateKey, 'base64');
|
||||
|
||||
return (
|
||||
'-----BEGIN CERTIFICATE-----\n' +
|
||||
Buffer.from(certData.publicKey).toString('base64') +
|
||||
'\n' +
|
||||
signature +
|
||||
'\n-----END CERTIFICATE-----\n'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const tapNodeTools = new TapNodeTools();
|
1
ts_node/index.ts
Normal file
1
ts_node/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './classes.tapnodetools.js';
|
10
ts_node/plugins.ts
Normal file
10
ts_node/plugins.ts
Normal file
@ -0,0 +1,10 @@
|
||||
// node native
|
||||
import * as crypto from 'crypto';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export { crypto,fs };
|
||||
|
||||
// @push.rocks scope
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
|
||||
export { smartshell };
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
17
tslint.json
17
tslint.json
@ -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"
|
||||
}
|
Reference in New Issue
Block a user