Compare commits
71 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
02ff220c59 | |||
035cb84442 | |||
505f624dd9 | |||
ea5fbd4637 | |||
de780538a5 | |||
28b1f0bfed | |||
72b72a9ffb | |||
be393199be |
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
|
150
.gitlab-ci.yml
150
.gitlab-ci.yml
@ -1,16 +1,16 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
@ -18,108 +18,114 @@ stages:
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- docker
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
only:
|
||||
- tags
|
||||
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]
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g npmpage
|
||||
- npmci command npmpage
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
@ -127,15 +133,5 @@ pages:
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
||||
windowsCompatibility:
|
||||
image: stefanscherer/node-windows:10-build-tools
|
||||
stage: metadata
|
||||
script:
|
||||
- npm install & npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- windows
|
||||
- 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: {}
|
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", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
29
README.md
29
README.md
@ -1,29 +0,0 @@
|
||||
# @pushrocks/tapbundle
|
||||
|
||||
tap bundled for tapbuffer
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/tapbundle)
|
||||
[](https://GitLab.com/pushrocks/tapbundle)
|
||||
[](https://github.com/pushrocks/tapbundle)
|
||||
[](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/tapbundle)
|
||||
[](https://david-dm.org/pushrocks/tapbundle)
|
||||
[](https://www.bithound.io/github/pushrocks/tapbundle/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/tapbundle)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
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://push.rocks)
|
@ -1,56 +0,0 @@
|
||||
# Get Started
|
||||
|
||||
## TypeScript
|
||||
|
||||
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://push.rocks)
|
@ -1,29 +0,0 @@
|
||||
# tapbundle
|
||||
|
||||
tap bundled for tapbuffer
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/tapbundle)
|
||||
[](https://GitLab.com/pushrocks/tapbundle)
|
||||
[](https://github.com/pushrocks/tapbundle)
|
||||
[](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/tapbundle)
|
||||
[](https://david-dm.org/pushrocks/tapbundle)
|
||||
[](https://www.bithound.io/github/pushrocks/tapbundle/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/tapbundle)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
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://push.rocks)
|
@ -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>
|
@ -1,7 +1,6 @@
|
||||
# License
|
||||
|
||||
**MIT License**
|
||||
|
||||
Copright © 2016 Lossless GmbH
|
||||
Copyright © 2016 - 2017 Martin Donath
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
@ -7,5 +7,16 @@
|
||||
"testConfig": {
|
||||
"parallel": false
|
||||
}
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitrepo": "tapbundle",
|
||||
"shortDescription": "tap bundled for tapbuffer",
|
||||
"npmPackagename": "@pushrocks/tapbundle",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
27848
package-lock.json
generated
27848
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
48
package.json
48
package.json
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@pushrocks/tapbundle",
|
||||
"private": false,
|
||||
"version": "3.0.4",
|
||||
"version": "4.0.7",
|
||||
"description": "tap bundled for tapbuffer",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -20,17 +20,35 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
||||
"dependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.13",
|
||||
"@pushrocks/early": "^3.0.3",
|
||||
"@pushrocks/smartdelay": "^2.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"leakage": "^0.4.0",
|
||||
"smartchai": "^2.0.1"
|
||||
"@open-wc/testing-helpers": "^2.0.4",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"@pushrocks/smartexpect": "^1.0.12",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smarttime": "^3.0.45"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsrun": "^1.1.12",
|
||||
"@types/node": "^10.5.7",
|
||||
"randomstring": "^1.1.5"
|
||||
}
|
||||
"@gitzone/tsbuild": "^2.1.29",
|
||||
"@gitzone/tsrun": "^1.2.18",
|
||||
"@gitzone/tstest": "^1.0.64",
|
||||
"@types/node": "^17.0.18",
|
||||
"randomstring": "^1.2.2",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
88
readme.md
Normal file
88
readme.md
Normal file
@ -0,0 +1,88 @@
|
||||
# @pushrocks/tapbundle
|
||||
tap based testing framework for use with @gitzone/tstest
|
||||
|
||||
## 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
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
A few words on TypeScript
|
||||
|
||||
### Included in this package
|
||||
|
||||
* tap compatible testing framework written in TypeScript
|
||||
* `expect` and `expectAsync` from the package `@pushrocks/smartexpect`
|
||||
|
||||
### A few words on tap
|
||||
|
||||
**"tap"** stands for **"test anything protocol"**. Its programming language agnostic as long as the test interpreter can read the tap console output. This package is optimized to work with @gitzone/tstest as interpreter, which offers different V8 based runtime environments like nodejs, chrome, and deno.
|
||||
|
||||
### Write your first tests
|
||||
|
||||
```typescript
|
||||
import { tap, expect, expectAsync } from 'tapbundle'; // has typings in place
|
||||
|
||||
import * as myAwesomeModuleToTest from '../dist/index'; // '../dist/index' is the standard path for npmts modules
|
||||
|
||||
tap.test('my awesome description', async (tools) => {
|
||||
// tools are optional parameter
|
||||
tools.timeout(2000); // test will fail if it takes longer than 2000 millisenconds
|
||||
});
|
||||
|
||||
const 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).toBeTrue(); // will not throw
|
||||
await expectAsync(tools.delayFor(2000)).toBeUndefined(); // yay expect promises :)
|
||||
expectAsync(myTest2.promise) // access other tests metadata :)
|
||||
.property('hrtMeasurement') // and drill down into properties
|
||||
.property('milliSeconds').toBeGreaterThan(1000);
|
||||
});
|
||||
|
||||
const 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).toEqual('pending'); // since this test will likely finish before myTest4.
|
||||
});
|
||||
|
||||
tap.start(); // start the test, will automtically plan tests for you (so the tap parser knows when tests exit bofore they are finished)
|
||||
```
|
||||
|
||||
## Contribution
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
45
test/test.browser.ts
Normal file
45
test/test.browser.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { tap, expect, webhelpers } from '../ts/index';
|
||||
|
||||
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).hrtMeasurement.milliSeconds < (await test2).hrtMeasurement.milliSeconds).toBeTrue();
|
||||
expect((await test2).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);
|
||||
});
|
||||
|
||||
tap.start();
|
@ -1,21 +0,0 @@
|
||||
import { tap, expect } from '../ts/index';
|
||||
import * as randomstring from 'randomstring';
|
||||
|
||||
let test1 = tap.test('my first test -> expect true to be true', async tools => {
|
||||
await tools.checkIterationLeak(async () => {
|
||||
let domain = randomstring.generate(1000);
|
||||
});
|
||||
});
|
||||
|
||||
let outsideArray = [];
|
||||
|
||||
let test2 = tap.test('should throw', async tools => {
|
||||
let err = await tools.returnError(async () => {
|
||||
await tools.checkIterationLeak(async () => {
|
||||
outsideArray.push(randomstring.generate(1000));
|
||||
});
|
||||
});
|
||||
expect(err).to.be.instanceof(Error);
|
||||
});
|
||||
|
||||
tap.start();
|
@ -1,10 +1,5 @@
|
||||
import { tap, expect } from '../ts/index';
|
||||
import { tap, expect, TapWrap } from '../ts/index';
|
||||
|
||||
let 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();
|
||||
|
30
test/test.ts
30
test/test.ts
@ -1,33 +1,41 @@
|
||||
import { tap, expect } from '../ts/index';
|
||||
|
||||
let 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');
|
||||
});
|
||||
|
||||
let 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);
|
||||
});
|
||||
|
||||
let test3 = tap.test(
|
||||
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();
|
||||
}
|
||||
);
|
||||
|
||||
let 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';
|
||||
});
|
||||
|
||||
let 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);
|
||||
});
|
||||
|
||||
let 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);
|
||||
|
10
ts/index.ts
10
ts/index.ts
@ -1,2 +1,10 @@
|
||||
export { expect } from 'smartchai';
|
||||
export { tap } from './tapbundle.classes.tap';
|
||||
export { TapWrap } from './tapbundle.classes.tapwrap';
|
||||
export { webhelpers } from './webhelpers';
|
||||
|
||||
import { expect, expectAsync } from '@pushrocks/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';
|
||||
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,39 +1,59 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
|
||||
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask';
|
||||
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
|
||||
import { TapWrap, ITapWrapFunction } from './tapbundle.classes.tapwrap';
|
||||
export class Tap {
|
||||
export class Tap <T> {
|
||||
/**
|
||||
* skip a test
|
||||
* 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<T>) => {
|
||||
console.log(`skipped test: ${descriptionArg}`);
|
||||
},
|
||||
};
|
||||
|
||||
private _tapTests: TapTest[] = [];
|
||||
/**
|
||||
* only executes tests marked as ONLY
|
||||
*/
|
||||
public only = {
|
||||
test: (descriptionArg: string, testFunctionArg: ITestFunction<T>) => {
|
||||
this.test(descriptionArg, testFunctionArg, 'only');
|
||||
},
|
||||
};
|
||||
|
||||
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(testDescription: string, testFunction: ITestFunction) {
|
||||
let localTest = new TapTest({
|
||||
public test(
|
||||
testDescription: string,
|
||||
testFunction: ITestFunction<T>,
|
||||
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
||||
): TapTest<T> {
|
||||
const localTest = new TapTest<T>({
|
||||
description: testDescription,
|
||||
testFunction: testFunction,
|
||||
parallel: false
|
||||
testFunction,
|
||||
parallel: false,
|
||||
});
|
||||
this._tapTests.push(localTest);
|
||||
if (modeArg === 'normal') {
|
||||
this._tapTests.push(localTest);
|
||||
} else if (modeArg === 'only') {
|
||||
this._tapTestsOnly.push(localTest);
|
||||
}
|
||||
return localTest;
|
||||
}
|
||||
|
||||
/**
|
||||
* wraps function
|
||||
*/
|
||||
wrap(functionArg: ITapWrapFunction) {
|
||||
return new TapWrap(functionArg);
|
||||
public preTask(descriptionArg: string, functionArg: IPreTaskFunction) {
|
||||
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,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,
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -54,19 +74,40 @@ 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;
|
||||
}
|
||||
|
||||
console.log(`1..${this._tapTests.length}`);
|
||||
for (let testKey = 0; testKey < this._tapTests.length; testKey++) {
|
||||
let currentTest = this._tapTests[testKey];
|
||||
let testPromise = currentTest.run(testKey);
|
||||
// determine which tests to run
|
||||
let concerningTests: TapTest[];
|
||||
if (this._tapTestsOnly.length > 0) {
|
||||
concerningTests = this._tapTestsOnly;
|
||||
} else {
|
||||
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++) {
|
||||
const currentTest = concerningTests[testKey];
|
||||
const testPromise = currentTest.run(testKey);
|
||||
if (currentTest.parallel) {
|
||||
promiseArray.push(testPromise);
|
||||
} else {
|
||||
@ -76,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 this._tapTests) {
|
||||
for (const tapTest of concerningTests) {
|
||||
if (tapTest.status !== 'success') {
|
||||
failReasons.push(
|
||||
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
||||
@ -90,19 +131,22 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* handle errors
|
||||
*/
|
||||
threw(err) {
|
||||
public threw(err: Error) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
@ -3,31 +3,31 @@ import { tapCreator } from './tapbundle.tapcreator';
|
||||
import { TapTools } from './tapbundle.classes.taptools';
|
||||
|
||||
// imported interfaces
|
||||
import { HrtMeasurement } from '@pushrocks/early';
|
||||
import { Deferred } from 'smartq';
|
||||
import { Deferred } from '@pushrocks/smartpromise';
|
||||
import { HrtMeasurement } from '@pushrocks/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 +39,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 +54,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') {
|
||||
|
@ -11,30 +11,30 @@ export class TapTools {
|
||||
*/
|
||||
private _tapTest: TapTest;
|
||||
|
||||
constructor(TapTestArg) {
|
||||
constructor(TapTestArg: TapTest<any>) {
|
||||
this._tapTest = TapTestArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* allow failure
|
||||
*/
|
||||
allowFailure() {
|
||||
public allowFailure() {
|
||||
this._tapTest.failureAllowed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* async/await delay method
|
||||
*/
|
||||
async delayFor(timeMilliArg) {
|
||||
public async delayFor(timeMilliArg: number) {
|
||||
await plugins.smartdelay.delayFor(timeMilliArg);
|
||||
}
|
||||
|
||||
async delayForRandom(timeMilliMinArg, timeMilliMaxArg) {
|
||||
public async delayForRandom(timeMilliMinArg: number, timeMilliMaxArg: number) {
|
||||
await plugins.smartdelay.delayForRandom(timeMilliMinArg, timeMilliMaxArg);
|
||||
}
|
||||
|
||||
async timeout(timeMilliArg: number) {
|
||||
let timeout = new plugins.smartdelay.Timeout(timeMilliArg);
|
||||
public async timeout(timeMilliArg: number) {
|
||||
const timeout = new plugins.smartdelay.Timeout(timeMilliArg);
|
||||
timeout.makeUnrefed();
|
||||
await timeout.promise;
|
||||
if (this._tapTest.status === 'pending') {
|
||||
@ -42,17 +42,17 @@ export class TapTools {
|
||||
}
|
||||
}
|
||||
|
||||
async checkIterationLeak(iterationfuncArg: IPromiseFunc) {
|
||||
await plugins.leakage.iterate.async(iterationfuncArg);
|
||||
}
|
||||
|
||||
async returnError(throwingFuncArg: IPromiseFunc) {
|
||||
public async returnError(throwingFuncArg: IPromiseFunc) {
|
||||
let funcErr: Error;
|
||||
try {
|
||||
await throwingFuncArg();
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
funcErr = err;
|
||||
}
|
||||
return funcErr;
|
||||
}
|
||||
|
||||
public defer() {
|
||||
return plugins.smartpromise.defer();
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,13 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
|
||||
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,7 @@
|
||||
import * as early from '@pushrocks/early';
|
||||
import * as leakage from 'leakage';
|
||||
// pushrocks
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartenv from '@pushrocks/smartenv';
|
||||
import * as smartexpect from '@pushrocks/smartexpect';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export { early, smartdelay, smartpromise, leakage };
|
||||
export { smartdelay, smartenv, smartexpect, smartpromise };
|
||||
|
25
ts/webhelpers.ts
Normal file
25
ts/webhelpers.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import * as plugins from './tapbundle.plugins';
|
||||
import type { fixture, html } from '@open-wc/testing-helpers';
|
||||
import { tap } from './tapbundle.classes.tap';
|
||||
|
||||
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-helpers')
|
||||
this.html = webhelpers.html;
|
||||
this.fixture = webhelpers.fixture;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const webhelpers = new WebHelpers();
|
16
tslint.json
16
tslint.json
@ -1,3 +1,17 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
"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