Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
a00536996c | |||
66f49cf8aa | |||
aa3f1eb21f | |||
d81a8006b1 | |||
5fa4c1cd85 | |||
fc609858ff | |||
19ecca0179 | |||
ff55e596cb | |||
ed8c8312c2 | |||
a6dd8de0db | |||
081347b23b | |||
f23575a8a2 | |||
b2dbc9160b | |||
1e8ab2d7a2 | |||
427878763e | |||
bdcc94e723 | |||
3ac46b2363 | |||
deae532820 | |||
99883eab82 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -1,18 +1,16 @@
|
|||||||
# gitzone ci_default
|
# gitzone ci_default
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
variables:
|
|
||||||
GIT_STRATEGY: clone
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@ -20,60 +18,66 @@ stages:
|
|||||||
mirror:
|
mirror:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# metadata stage
|
# metadata stage
|
||||||
@ -83,33 +87,35 @@ codequality:
|
|||||||
allow_failure: true
|
allow_failure: true
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-dbase:npmci
|
|
||||||
services:
|
|
||||||
- docker:18-dind
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
|
- npmci node install lts
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -117,5 +123,5 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${relativeFile}"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "test.ts",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"test/test.ts"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -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,6 +9,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
|
11295
package-lock.json
generated
11295
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/tapbundle",
|
"name": "@pushrocks/tapbundle",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "3.0.13",
|
"version": "3.2.6",
|
||||||
"description": "tap bundled for tapbuffer",
|
"description": "tap bundled for tapbuffer",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -20,27 +20,29 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/smartdelay": "^2.0.9",
|
||||||
"@pushrocks/smartdelay": "^2.0.3",
|
"@pushrocks/smartenv": "^4.0.10",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
|
"@pushrocks/smarttime": "^3.0.19",
|
||||||
"smartchai": "^2.0.1"
|
"smartchai": "^2.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@gitzone/tsbuild": "^2.1.24",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@gitzone/tstest": "^1.0.36",
|
||||||
"@types/node": "^12.7.2",
|
"@types/node": "^14.0.19",
|
||||||
"randomstring": "^1.1.5",
|
"randomstring": "^1.1.5",
|
||||||
"tslint": "^5.19.0",
|
"tslint": "^6.1.2",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/**/*",
|
||||||
"ts_web/*",
|
"ts_web/**/*",
|
||||||
"dist/*",
|
"dist/**/*",
|
||||||
"dist_web/*",
|
"dist_*/**/*",
|
||||||
"dist_ts_web/*",
|
"dist_ts/**/*",
|
||||||
"assets/*",
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
@ -64,6 +64,10 @@ tap.test('my awesome test 5', async () => {
|
|||||||
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)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
40
test/test.browser.ts
Normal file
40
test/test.browser.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { tap, expect } from '../ts/index';
|
||||||
|
|
||||||
|
tap.preTask('hi there', async () => {
|
||||||
|
console.log('this is a pretask');
|
||||||
|
});
|
||||||
|
|
||||||
|
const test1 = tap.test('my first test -> expect true to be true', async () => {
|
||||||
|
return expect(true).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const test2 = tap.test('my second test', async (tools) => {
|
||||||
|
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).hrtMeasurement.milliSeconds < (await test2).hrtMeasurement.milliSeconds).to
|
||||||
|
.be.true;
|
||||||
|
expect((await test2).hrtMeasurement.milliSeconds > 10).to.be.true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
|
||||||
|
tools.allowFailure();
|
||||||
|
expect(false).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,7 +1,7 @@
|
|||||||
import { tap, expect } from '../ts/index';
|
import { tap, expect } from '../ts/index';
|
||||||
import * as randomstring from 'randomstring';
|
import * as randomstring from 'randomstring';
|
||||||
|
|
||||||
const test1 = tap.test('my first test -> expect true to be true', async tools => {
|
const test1 = tap.test('my first test -> expect true to be true', async (tools) => {
|
||||||
await tools.checkIterationLeak(async () => {
|
await tools.checkIterationLeak(async () => {
|
||||||
const domain = randomstring.generate(1000);
|
const domain = randomstring.generate(1000);
|
||||||
});
|
});
|
||||||
@ -9,7 +9,7 @@ const test1 = tap.test('my first test -> expect true to be true', async tools =>
|
|||||||
|
|
||||||
const outsideArray = [];
|
const outsideArray = [];
|
||||||
|
|
||||||
const test2 = tap.test('should throw', async tools => {
|
const test2 = tap.test('should throw', async (tools) => {
|
||||||
const err = await tools.returnError(async () => {
|
const err = await tools.returnError(async () => {
|
||||||
await tools.checkIterationLeak(async () => {
|
await tools.checkIterationLeak(async () => {
|
||||||
outsideArray.push(randomstring.generate(1000));
|
outsideArray.push(randomstring.generate(1000));
|
||||||
|
12
test/test.ts
12
test/test.ts
@ -1,10 +1,14 @@
|
|||||||
import { tap, expect } from '../ts/index';
|
import { tap, expect } from '../ts/index';
|
||||||
|
|
||||||
|
tap.preTask('hi there', async () => {
|
||||||
|
console.log('this is a pretask');
|
||||||
|
});
|
||||||
|
|
||||||
const test1 = tap.test('my first test -> expect true to be true', async () => {
|
const test1 = tap.test('my first test -> expect true to be true', async () => {
|
||||||
return expect(true).to.be.true;
|
return expect(true).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const test2 = tap.test('my second test', async tools => {
|
const test2 = tap.test('my second test', async (tools) => {
|
||||||
await tools.delayFor(1000);
|
await tools.delayFor(1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -17,17 +21,17 @@ const test3 = tap.test(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const test4 = tap.skip.test('my 4th test -> should fail', async tools => {
|
const test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
|
||||||
tools.allowFailure();
|
tools.allowFailure();
|
||||||
expect(false).to.be.true;
|
expect(false).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
const test5 = tap.test('my 5th test -> should pass in about 500ms', async tools => {
|
const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {
|
||||||
tools.timeout(1000);
|
tools.timeout(1000);
|
||||||
await tools.delayFor(500);
|
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.allowFailure();
|
||||||
tools.timeout(1000);
|
tools.timeout(1000);
|
||||||
await tools.delayFor(2000);
|
await tools.delayFor(2000);
|
||||||
|
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';
|
||||||
|
import { TapTools } from './tapbundle.classes.taptools';
|
||||||
|
|
||||||
|
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,5 +1,6 @@
|
|||||||
import * as plugins from './tapbundle.plugins';
|
import * as plugins from './tapbundle.plugins';
|
||||||
|
|
||||||
|
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask';
|
||||||
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
||||||
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
|
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
|
||||||
export class Tap {
|
export class Tap {
|
||||||
@ -7,24 +8,25 @@ 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
|
||||||
*/
|
*/
|
||||||
skip = {
|
public skip = {
|
||||||
test: (descriptionArg: string, functionArg: ITestFunction) => {
|
test: (descriptionArg: string, functionArg: ITestFunction) => {
|
||||||
console.log(`skipped test: ${descriptionArg}`);
|
console.log(`skipped test: ${descriptionArg}`);
|
||||||
},
|
},
|
||||||
testParallel: (descriptionArg: string, functionArg: ITestFunction) => {
|
testParallel: (descriptionArg: string, functionArg: ITestFunction) => {
|
||||||
console.log(`skipped test: ${descriptionArg}`);
|
console.log(`skipped test: ${descriptionArg}`);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* only executes tests marked as ONLY
|
* only executes tests marked as ONLY
|
||||||
*/
|
*/
|
||||||
only = {
|
public only = {
|
||||||
test: (descriptionArg: string, testFunctionArg: ITestFunction) => {
|
test: (descriptionArg: string, testFunctionArg: ITestFunction) => {
|
||||||
this.test(descriptionArg, testFunctionArg, 'only');
|
this.test(descriptionArg, testFunctionArg, 'only');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _tapPreTasks: PreTask[] = [];
|
||||||
private _tapTests: TapTest[] = [];
|
private _tapTests: TapTest[] = [];
|
||||||
private _tapTestsOnly: TapTest[] = [];
|
private _tapTestsOnly: TapTest[] = [];
|
||||||
|
|
||||||
@ -33,15 +35,15 @@ export class Tap {
|
|||||||
* @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
|
||||||
*/
|
*/
|
||||||
async test(
|
public async test(
|
||||||
testDescription: string,
|
testDescription: string,
|
||||||
testFunction: ITestFunction,
|
testFunction: ITestFunction,
|
||||||
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
||||||
) {
|
) {
|
||||||
let localTest = new TapTest({
|
const localTest = new TapTest({
|
||||||
description: testDescription,
|
description: testDescription,
|
||||||
testFunction: testFunction,
|
testFunction,
|
||||||
parallel: false
|
parallel: false,
|
||||||
});
|
});
|
||||||
if (modeArg === 'normal') {
|
if (modeArg === 'normal') {
|
||||||
this._tapTests.push(localTest);
|
this._tapTests.push(localTest);
|
||||||
@ -51,10 +53,14 @@ export class Tap {
|
|||||||
return localTest;
|
return localTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public preTask(descriptionArg: string, functionArg: IPreTaskFunction) {
|
||||||
|
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wraps function
|
* wraps function
|
||||||
*/
|
*/
|
||||||
wrap(functionArg: ITapWrapFunction) {
|
public wrap(functionArg: ITapWrapFunction) {
|
||||||
return new TapWrap(functionArg);
|
return new TapWrap(functionArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,12 +69,12 @@ export class Tap {
|
|||||||
* @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
|
||||||
*/
|
*/
|
||||||
testParallel(testDescription: string, testFunction: ITestFunction) {
|
public testParallel(testDescription: string, testFunction: ITestFunction) {
|
||||||
this._tapTests.push(
|
this._tapTests.push(
|
||||||
new TapTest({
|
new TapTest({
|
||||||
description: testDescription,
|
description: testDescription,
|
||||||
testFunction: testFunction,
|
testFunction,
|
||||||
parallel: true
|
parallel: true,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -76,12 +82,20 @@ export class Tap {
|
|||||||
/**
|
/**
|
||||||
* starts the test evaluation
|
* starts the test evaluation
|
||||||
*/
|
*/
|
||||||
async start(optionsArg?: { throwOnError: boolean }) {
|
public async start(optionsArg?: { throwOnError: boolean }) {
|
||||||
let promiseArray: Promise<any>[] = [];
|
// lets set the tapbundle promise
|
||||||
|
const smartenvInstance = new plugins.smartenv.Smartenv();
|
||||||
|
smartenvInstance.isBrowser
|
||||||
|
? (globalThis.tapbundleDeferred = plugins.smartpromise.defer())
|
||||||
|
: null;
|
||||||
|
|
||||||
|
// lets continue with running the tests
|
||||||
|
const promiseArray: Array<Promise<any>> = [];
|
||||||
|
|
||||||
// safeguard against empty test array
|
// safeguard against empty test array
|
||||||
if (this._tapTests.length === 0) {
|
if (this._tapTests.length === 0) {
|
||||||
console.log('no tests specified. Ending here!');
|
console.log('no tests specified. Ending here!');
|
||||||
|
// TODO: throw proper error
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,10 +107,15 @@ export class Tap {
|
|||||||
concerningTests = this._tapTests;
|
concerningTests = this._tapTests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lets run the pretasks
|
||||||
|
for (const preTask of this._tapPreTasks) {
|
||||||
|
await preTask.run();
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`1..${concerningTests.length}`);
|
console.log(`1..${concerningTests.length}`);
|
||||||
for (let testKey = 0; testKey < concerningTests.length; testKey++) {
|
for (let testKey = 0; testKey < concerningTests.length; testKey++) {
|
||||||
let currentTest = concerningTests[testKey];
|
const currentTest = concerningTests[testKey];
|
||||||
let testPromise = currentTest.run(testKey);
|
const testPromise = currentTest.run(testKey);
|
||||||
if (currentTest.parallel) {
|
if (currentTest.parallel) {
|
||||||
promiseArray.push(testPromise);
|
promiseArray.push(testPromise);
|
||||||
} else {
|
} else {
|
||||||
@ -106,10 +125,10 @@ export class Tap {
|
|||||||
await Promise.all(promiseArray);
|
await Promise.all(promiseArray);
|
||||||
|
|
||||||
// when tests have been run and all promises are fullfilled
|
// when tests have been run and all promises are fullfilled
|
||||||
let failReasons: string[] = [];
|
const failReasons: string[] = [];
|
||||||
let executionNotes: string[] = [];
|
const executionNotes: string[] = [];
|
||||||
// collect failed tests
|
// collect failed tests
|
||||||
for (let tapTest of concerningTests) {
|
for (const tapTest of concerningTests) {
|
||||||
if (tapTest.status !== 'success') {
|
if (tapTest.status !== 'success') {
|
||||||
failReasons.push(
|
failReasons.push(
|
||||||
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
||||||
@ -120,7 +139,7 @@ export class Tap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// render fail Reasons
|
// render fail Reasons
|
||||||
for (let failReason of failReasons) {
|
for (const failReason of failReasons) {
|
||||||
console.log(failReason);
|
console.log(failReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +151,7 @@ export class Tap {
|
|||||||
/**
|
/**
|
||||||
* handle errors
|
* handle errors
|
||||||
*/
|
*/
|
||||||
threw(err) {
|
public threw(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,27 +3,25 @@ import { tapCreator } from './tapbundle.tapcreator';
|
|||||||
import { TapTools } from './tapbundle.classes.taptools';
|
import { TapTools } from './tapbundle.classes.taptools';
|
||||||
|
|
||||||
// imported interfaces
|
// imported interfaces
|
||||||
import { HrtMeasurement } from '@pushrocks/early';
|
|
||||||
import { Deferred } from '@pushrocks/smartpromise';
|
import { Deferred } from '@pushrocks/smartpromise';
|
||||||
|
import { HrtMeasurement } from '@pushrocks/smarttime';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
|
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
|
||||||
|
|
||||||
export interface ITestFunction {
|
export type ITestFunction = (tapTools?: TapTools) => Promise<any>;
|
||||||
(tapTools?: TapTools): Promise<any>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class TapTest {
|
export class TapTest {
|
||||||
description: string;
|
public description: string;
|
||||||
failureAllowed: boolean;
|
public failureAllowed: boolean;
|
||||||
hrtMeasurement: HrtMeasurement;
|
public hrtMeasurement: HrtMeasurement;
|
||||||
parallel: boolean;
|
public parallel: boolean;
|
||||||
status: TTestStatus;
|
public status: TTestStatus;
|
||||||
tapTools: TapTools;
|
public tapTools: TapTools;
|
||||||
testFunction: ITestFunction;
|
public testFunction: ITestFunction;
|
||||||
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()
|
||||||
testDeferred: Deferred<TapTest> = plugins.smartpromise.defer();
|
public testDeferred: Deferred<TapTest> = plugins.smartpromise.defer();
|
||||||
testPromise: Promise<TapTest> = this.testDeferred.promise;
|
public testPromise: Promise<TapTest> = this.testDeferred.promise;
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*/
|
*/
|
||||||
@ -39,10 +37,10 @@ export class TapTest {
|
|||||||
/**
|
/**
|
||||||
* run the test
|
* run the test
|
||||||
*/
|
*/
|
||||||
async run(testKeyArg: number) {
|
public async run(testKeyArg: number) {
|
||||||
this.hrtMeasurement.start();
|
this.hrtMeasurement.start();
|
||||||
this.testKey = testKeyArg;
|
this.testKey = testKeyArg;
|
||||||
let testNumber = testKeyArg + 1;
|
const testNumber = testKeyArg + 1;
|
||||||
try {
|
try {
|
||||||
await this.testFunction(this.tapTools);
|
await this.testFunction(this.tapTools);
|
||||||
if (this.status === 'timeout') {
|
if (this.status === 'timeout') {
|
||||||
|
@ -19,6 +19,7 @@ export class TapWrap {
|
|||||||
* run the wrapFunction
|
* run the wrapFunction
|
||||||
*/
|
*/
|
||||||
async run() {
|
async run() {
|
||||||
|
// TODO: make sure it makes sense what we do here.
|
||||||
await this.wrapFunction();
|
await this.wrapFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// pushrocks
|
// pushrocks
|
||||||
import * as early from '@pushrocks/early';
|
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
import * as smartenv from '@pushrocks/smartenv';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
export { early, smartdelay, smartpromise };
|
export { smartdelay, smartenv, smartpromise };
|
||||||
|
|
||||||
// third party
|
// third party
|
||||||
/* import * as leakage from 'leakage';
|
/* import * as leakage from 'leakage';
|
||||||
|
Reference in New Issue
Block a user