Compare commits

...

113 Commits

Author SHA1 Message Date
14b95cfbc3 4.0.0 2022-01-21 19:54:08 +01:00
0884da7941 BREAKING CHANGE(core): switxh to @pushrocks/smartexpect 2022-01-21 19:54:07 +01:00
22df58b8bc 3.2.15 2021-12-10 17:34:06 +01:00
33399126f7 fix(core): update 2021-12-10 17:34:06 +01:00
d1e46fd2a7 3.2.14 2021-02-13 16:06:38 +00:00
9304e6d736 fix(core): update 2021-02-13 16:06:38 +00:00
588c532d6d 3.2.13 2021-02-13 16:02:40 +00:00
e3a756c775 fix(core): update 2021-02-13 16:02:40 +00:00
05defe6031 3.2.12 2021-01-26 03:19:50 +00:00
f4bb17dea1 fix(core): update 2021-01-26 03:19:49 +00:00
1023a94ff2 3.2.11 2021-01-26 03:15:50 +00:00
8ee456da5f fix(core): update 2021-01-26 03:15:50 +00:00
45ee6eca31 3.2.10 2021-01-26 02:35:03 +00:00
1eaf1e9a77 fix(core): update 2021-01-26 02:35:02 +00:00
715108b11b 3.2.9 2020-07-11 16:07:53 +00:00
7b1e8f47b1 fix(core): update 2020-07-11 16:07:52 +00:00
2b71ffe8c2 3.2.8 2020-07-11 16:07:31 +00:00
29ec99e63e fix(core): update 2020-07-11 16:07:30 +00:00
50f1aad895 3.2.7 2020-07-08 00:46:44 +00:00
f7e95df2b9 fix(core): update 2020-07-08 00:46:43 +00:00
a00536996c 3.2.6 2020-07-08 00:17:32 +00:00
66f49cf8aa fix(core): update 2020-07-08 00:17:31 +00:00
aa3f1eb21f update readme 2020-07-08 00:17:25 +00:00
d81a8006b1 3.2.5 2020-07-08 00:16:10 +00:00
5fa4c1cd85 fix(core): update 2020-07-08 00:16:09 +00:00
fc609858ff 3.2.4 2020-07-08 00:15:45 +00:00
19ecca0179 fix(core): update 2020-07-08 00:15:44 +00:00
ff55e596cb 3.2.3 2020-07-08 00:11:16 +00:00
ed8c8312c2 fix(core): update 2020-07-08 00:11:16 +00:00
a6dd8de0db 3.2.2 2020-07-07 22:54:15 +00:00
081347b23b fix(core): update 2020-07-07 22:54:15 +00:00
f23575a8a2 3.2.1 2020-03-15 16:36:26 +00:00
b2dbc9160b fix(core): update 2020-03-15 16:36:25 +00:00
1e8ab2d7a2 3.2.0 2019-11-16 23:40:38 +01:00
427878763e feat(pretask): introduce new pretask functionality for setting up testing environment 2019-11-16 23:40:36 +01:00
bdcc94e723 3.1.0 2019-11-16 19:22:21 +01:00
3ac46b2363 feat(tools): can now ensure certain directories 2019-11-16 19:22:20 +01:00
deae532820 3.0.14 2019-11-16 18:45:48 +01:00
99883eab82 fix(core): update 2019-11-16 18:45:47 +01:00
e27e59bbeb 3.0.13 2019-08-23 00:05:22 +02:00
fa54431280 fix(core): update 2019-08-23 00:05:21 +02:00
aa7c49548c 3.0.12 2019-08-22 23:57:28 +02:00
8d5352d000 fix(core): update 2019-08-22 23:57:27 +02:00
c3ae0bc211 3.0.11 2019-06-19 14:49:24 +02:00
0381f63b65 fix(core): update 2019-06-19 14:49:23 +02:00
f1441bf123 3.0.10 2019-06-19 13:18:46 +02:00
9892085140 fix(core): update 2019-06-19 13:18:45 +02:00
b6d1c3c083 3.0.9 2019-04-10 12:56:56 +02:00
6e6cfbadbd fix(core): update 2019-04-10 12:56:55 +02:00
02ff220c59 3.0.8 2019-04-10 12:56:18 +02:00
035cb84442 fix(core): update 2019-04-10 12:56:17 +02:00
505f624dd9 3.0.7 2018-09-03 00:01:53 +02:00
ea5fbd4637 fix(dependencies): update to latest versions 2018-09-03 00:01:53 +02:00
de780538a5 3.0.6 2018-09-02 23:54:59 +02:00
28b1f0bfed fix(core): add tap.only option 2018-09-02 23:54:59 +02:00
72b72a9ffb 3.0.5 2018-08-08 23:38:43 +02:00
be393199be fix(dependencies): update 2018-08-08 23:38:43 +02:00
7b6260bb15 3.0.4 2018-08-08 23:20:14 +02:00
2345e972d5 fix(dependencies): use @gitzone/tsbuild instead of npmts 2018-08-08 23:20:14 +02:00
22c44a8cd0 3.0.3 2018-08-08 23:17:06 +02:00
bae2aebf83 fix(dependencies): now typings-global free 2018-08-08 23:17:06 +02:00
5fe2358bfe 3.0.2 2018-07-18 08:31:22 +02:00
280ded573d fix(dependencies): update 2018-07-18 08:31:22 +02:00
6b6a92b709 3.0.1 2018-07-13 22:28:18 +02:00
c1589c2309 fix(package): npm access level 2018-07-13 22:28:17 +02:00
271d657f2c 3.0.0 2018-07-13 22:06:45 +02:00
63669ea6ff BREAKING CHANGE(package): change scope 2018-07-13 22:06:45 +02:00
4306272f45 2.0.2 2018-06-28 23:47:58 +02:00
4378b36069 fix(security): add snyk file 2018-06-28 23:47:57 +02:00
e8f7013435 2.0.1 2018-06-28 23:34:41 +02:00
3199943b59 fix(core): fix node 10.x.x compatibility 2018-06-28 23:34:41 +02:00
0028c5492b 2.0.0 2018-02-27 22:52:08 +01:00
e3b05cc43c update to use latest smartchai 2018-02-27 22:52:02 +01:00
f68da622d7 1.1.8 2017-10-11 14:18:17 +02:00
b7e57e8cdc update ci 2017-10-11 14:18:14 +02:00
93b46a1446 1.1.7 2017-10-11 14:01:07 +02:00
ca3ea788fd add new docs 2017-10-11 14:01:03 +02:00
94a1bd4839 1.1.6 2017-10-10 17:14:17 +02:00
6c960f9fbd now has working leak detection 2017-10-10 17:14:14 +02:00
f2eddb169f 1.1.5 2017-10-09 21:55:01 +02:00
ad2da38289 1.1.4 2017-10-09 21:55:00 +02:00
301b82a0fb 1.1.3 2017-10-09 21:54:57 +02:00
d28609b513 1.1.2 2017-10-09 21:54:49 +02:00
d82d4e2eae update to latest smartchai 2017-10-09 21:54:46 +02:00
d105bab740 1.1.1 2017-07-11 15:10:09 +02:00
a03bcf4583 tap now thows, fixes #1 2017-07-11 15:10:05 +02:00
2b21566fe1 1.1.0 2017-07-06 00:06:22 +02:00
d22fc1b688 now supports tap.wrap 2017-07-06 00:06:18 +02:00
15bbf7f10c introduce TapWrap 2017-07-05 17:57:28 +02:00
c5e068d5cd 1.0.14 2017-06-05 15:14:10 +02:00
95fa33df58 now timouts are unrefed making them non blocking for natural process exits 2017-06-05 15:14:07 +02:00
42933e6bb0 refactor some code 2017-06-04 19:08:36 +02:00
5010e882f6 1.0.13 2017-05-27 01:46:41 +02:00
055d36c74e not rejecting tests, but resolving with status when failing to avoid node error about unhandled rejection 2017-05-27 01:46:38 +02:00
e2ac035997 1.0.12 2017-05-05 00:04:45 +02:00
ec0d6004d5 fix typos 2017-05-05 00:04:42 +02:00
3bbca9b0b4 1.0.11 2017-05-04 23:15:14 +02:00
f16e25b413 update docs 2017-05-04 23:15:08 +02:00
36574d0f34 1.0.10 2017-04-28 11:00:28 +02:00
12ac28ba44 add skip method, wait for tapreporter is finished 2017-04-28 11:00:22 +02:00
1c80c25b14 Merge branch 'master' into 'master'
update to latest standards

See merge request !1
2017-04-28 07:49:58 +00:00
03614fe2ef update to latest standards 2017-04-28 07:49:57 +00:00
8be85e1b35 update docs 2017-04-23 22:31:16 +02:00
baf56089d7 1.0.9 2017-04-23 22:08:55 +02:00
42cd52a2f3 now has correct test time measurement 2017-04-23 22:08:52 +02:00
140f8a2499 1.0.8 2017-04-23 15:23:45 +02:00
952b6ec2a4 update docs 2017-04-23 15:23:40 +02:00
c8f2a76422 1.0.7 2017-04-23 14:35:20 +02:00
e640059715 implemet errorAfterSuccess 2017-04-23 14:35:16 +02:00
64fc6e636a 1.0.6 2017-04-23 11:10:16 +02:00
753c387325 implement tap myself 2017-04-23 11:10:13 +02:00
4e541b7986 1.0.5 2017-03-26 12:54:21 +02:00
b6cfc24613 remove typings for tap 2017-03-26 12:54:16 +02:00
26 changed files with 27880 additions and 1803 deletions

18
.gitignore vendored
View File

@ -1,4 +1,20 @@
node_modules/
.nogit/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,38 +1,76 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
testLEGACY:
stage: test
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci test legacy
coverage: /\d+.?\d+?\%\s*coverage/
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- 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
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
testLTS:
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci test lts
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testSTABLE:
testBuild:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
@ -40,32 +78,60 @@ testSTABLE:
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npmpage --publish gitlab
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

29
.vscode/launch.json vendored Normal file
View 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
View 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"]
}
}
}
}
}
}
]
}

View File

@ -1,42 +0,0 @@
# tapbundle
tap bundled for tapbuffer
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/tapbundle)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/tapbundle)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/tapbundle)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/tapbundle/)
## Status for master
[![build status](https://GitLab.com/pushrocks/tapbundle/badges/master/build.svg)](https://GitLab.com/pushrocks/tapbundle/commits/master)
[![coverage report](https://GitLab.com/pushrocks/tapbundle/badges/master/coverage.svg)](https://GitLab.com/pushrocks/tapbundle/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/tapbundle.svg)](https://www.npmjs.com/package/tapbundle)
[![Dependency Status](https://david-dm.org/pushrocks/tapbundle.svg)](https://david-dm.org/pushrocks/tapbundle)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/tapbundle/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/tapbundle/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/tapbundle/badges/code.svg)](https://www.bithound.io/github/pushrocks/tapbundle)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
note this package includes
* tap
* chai
* chai-as-promised
* @types/tap
* @types/chai
* @types/chai-as-promised
```javascript
import {tap, expect} from 'tapbundle' // has typings in place
```
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)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

4
dist/index.d.ts vendored
View File

@ -1,4 +0,0 @@
import 'typings-global';
import * as tap from 'tap';
import { expect } from 'smartchai';
export { tap, expect };

8
dist/index.js vendored
View File

@ -1,8 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const tap = require("tap");
exports.tap = tap;
const smartchai_1 = require("smartchai");
exports.expect = smartchai_1.expect;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwyQkFBMEI7QUFJeEIsa0JBQUc7QUFITCx5Q0FBa0M7QUFJaEMsb0NBQU0ifQ==

22
license Normal file
View File

@ -0,0 +1,22 @@
**MIT License**
Copright © 2016 Lossless GmbH
Copyright © 2016 - 2017 Martin Donath
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.

View File

@ -1,7 +1,22 @@
{
"npmci": {
"globalNpmTools": [
"npmts"
]
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"npmts": {
"testConfig": {
"parallel": false
}
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "tapbundle",
"shortDescription": "tap bundled for tapbuffer",
"npmPackagename": "@pushrocks/tapbundle",
"license": "MIT"
}
}
}

27075
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,13 @@
{
"name": "tapbundle",
"version": "1.0.4",
"name": "@pushrocks/tapbundle",
"private": false,
"version": "4.0.0",
"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": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --web)"
},
"repository": {
"type": "git",
@ -18,8 +20,35 @@
},
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
"dependencies": {
"smartchai": "^1.0.3",
"tap": "^10.3.0",
"typings-global": "^1.0.14"
}
"@open-wc/testing-helpers": "^2.0.2",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartenv": "^4.0.16",
"@pushrocks/smartexpect": "^1.0.7",
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smarttime": "^3.0.43"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.29",
"@gitzone/tsrun": "^1.2.18",
"@gitzone/tstest": "^1.0.60",
"@types/node": "^16.11.12",
"randomstring": "^1.2.1",
"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"
]
}

83
readme.md Normal file
View File

@ -0,0 +1,83 @@
# @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
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/tapbundle/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/tapbundle/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/tapbundle)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/tapbundle)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/tapbundle)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/tapbundle)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/tapbundle)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](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
- a collection of test tools
- **code** testing framework with typings
### Write your first tests
```javascript
import { tap, expect } from 'tapbundle'; // has typings in place
import * as myAwesomeModuleToTest from '../dist/index'; // '../dist/index' is the standard path for npmts modules
tap.test('my awesome description', async (tools) => {
// tools are optional parameter
tools.timeout(2000); // test will fail if it takes longer than 2000 millisenconds
});
let myTest2 = tap.test('my awesome test 2', async (tools) => {
myAwsomeModuleToTest.doSomethingAsync(); // we don't wait here
await tools.delayFor(3000); // yay! :) promise based timeouts :)
console.log('This gets logged 3000 ms into the test');
});
tap.test('my awesome test 3', async (tools) => {
expect(true).to.be.true; // will not throw
await expect(tools.delayFor(2000)).to.eventually.be.fulfilled; // yay expect promises :)
expect((await myTest2.promise).hrtMeasurement.milliSeconds > 1000).to.be.true; // access other tests metadata :)
});
let myTest4 = tap.testParallel('my awesome test 4', async (tools) => {
await tools.delayFor(4000);
console.log('logs to console after 4 seconds into this test');
});
tap.test('my awesome test 5', async () => {
expect(myTest4.status).to.equal('pending'); // since this test will likely finish before myTest4.
});
tap.start(); // start the test, will automtically plan tests for you (so the tap parser knows when tests exit bofore they are finished)
```
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

45
test/test.browser.ts Normal file
View 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();

5
test/test.tapwrap.ts Normal file
View File

@ -0,0 +1,5 @@
import { tap, expect, TapWrap } from '../ts/index';
tap.test('should run a test', async () => {});
tap.start();

44
test/test.ts Normal file
View File

@ -0,0 +1,44 @@
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).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.testPromise).hrtMeasurement.milliSeconds <
(await test2).hrtMeasurement.milliSeconds
).toBeTrue();
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).toBeTrue();
}
);
const test4 = tap.test('my 4th test -> should fail', async (tools) => {
tools.allowFailure();
expect(false).toBeFalse();
return 'hello';
});
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) => {
tools.allowFailure();
tools.timeout(1000);
await tools.delayFor(2000);
});
tap.start();

View File

@ -1,8 +1,10 @@
import 'typings-global'
import * as tap from 'tap'
import { 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 {
tap,
expect
expect,
expectAsync
}

View 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));
}
}

154
ts/tapbundle.classes.tap.ts Normal file
View File

@ -0,0 +1,154 @@
import * as plugins from './tapbundle.plugins';
import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask';
import { TapTest, ITestFunction } from './tapbundle.classes.taptest';
export class Tap <T> {
/**
* skips a test
* tests marked with tap.skip.test() are never executed
*/
public skip = {
test: (descriptionArg: string, functionArg: ITestFunction<T>) => {
console.log(`skipped test: ${descriptionArg}`);
},
testParallel: (descriptionArg: string, functionArg: ITestFunction<T>) => {
console.log(`skipped test: ${descriptionArg}`);
},
};
/**
* 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
*/
public test(
testDescription: string,
testFunction: ITestFunction<T>,
modeArg: 'normal' | 'only' | 'skip' = 'normal'
): TapTest<T> {
const localTest = new TapTest<T>({
description: testDescription,
testFunction,
parallel: false,
});
if (modeArg === 'normal') {
this._tapTests.push(localTest);
} else if (modeArg === 'only') {
this._tapTestsOnly.push(localTest);
}
return localTest;
}
public preTask(descriptionArg: string, functionArg: IPreTaskFunction) {
this._tapPreTasks.push(new PreTask(descriptionArg, functionArg));
}
/**
* A parallel test that will not be waited for before the next starts.
* @param testDescription - A description of what the test does
* @param testFunction - A Function that returns a Promise and resolves or rejects
*/
public testParallel(testDescription: string, testFunction: ITestFunction<T>) {
this._tapTests.push(
new TapTest({
description: testDescription,
testFunction,
parallel: true,
})
);
}
/**
* starts the test evaluation
*/
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;
}
// 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 {
await testPromise;
}
}
await Promise.all(promiseArray);
// when tests have been run and all promises are fullfilled
const failReasons: string[] = [];
const executionNotes: string[] = [];
// collect failed tests
for (const tapTest of concerningTests) {
if (tapTest.status !== 'success') {
failReasons.push(
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
`|| ${tapTest.description}\n` +
`|| for more information please take a look the logs above`
);
}
}
// render fail Reasons
for (const failReason of failReasons) {
console.log(failReason);
}
if (optionsArg && optionsArg.throwOnError && failReasons.length > 0) {
if (!smartenvInstance.isBrowser) process.exit(1);
}
if (smartenvInstance.isBrowser) {
(globalThis as any).tapbundleDeferred.resolve();
}
}
/**
* handle errors
*/
public threw(err: Error) {
console.log(err);
}
}
export let tap = new Tap();

View File

@ -0,0 +1,81 @@
import * as plugins from './tapbundle.plugins';
import { tapCreator } from './tapbundle.tapcreator';
import { TapTools } from './tapbundle.classes.taptools';
// imported interfaces
import { Deferred } from '@pushrocks/smartpromise';
import { HrtMeasurement } from '@pushrocks/smarttime';
// interfaces
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
export interface ITestFunction <T> { (tapTools?: TapTools): Promise<T> };
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<T>; parallel: boolean }) {
this.description = optionsArg.description;
this.hrtMeasurement = new HrtMeasurement();
this.parallel = optionsArg.parallel;
this.status = 'pending';
this.tapTools = new TapTools(this);
this.testFunction = optionsArg.testFunction;
}
/**
* run the test
*/
public async run(testKeyArg: number) {
this.hrtMeasurement.start();
this.testKey = testKeyArg;
const testNumber = testKeyArg + 1;
try {
const testReturnValue = await this.testFunction(this.tapTools);
if (this.status === 'timeout') {
throw new Error('Test succeeded, but timed out...');
}
this.hrtMeasurement.stop();
console.log(
`ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`
);
this.status = 'success';
this.testDeferred.resolve(this);
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') {
this.status = 'errorAfterSuccess';
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull');
} else {
this.status = 'error';
}
// if the test is allowed to fail
if (this.failureAllowed) {
console.log(`please note: failure allowed!`);
}
console.log(err);
}
}
}

View File

@ -0,0 +1,58 @@
import * as plugins from './tapbundle.plugins';
import { TapTest } from './tapbundle.classes.taptest';
export interface IPromiseFunc {
(): Promise<any>;
}
export class TapTools {
/**
* the referenced TapTest
*/
private _tapTest: TapTest;
constructor(TapTestArg: TapTest<any>) {
this._tapTest = TapTestArg;
}
/**
* allow failure
*/
public allowFailure() {
this._tapTest.failureAllowed = true;
}
/**
* async/await delay method
*/
public async delayFor(timeMilliArg: number) {
await plugins.smartdelay.delayFor(timeMilliArg);
}
public async delayForRandom(timeMilliMinArg: number, timeMilliMaxArg: number) {
await plugins.smartdelay.delayForRandom(timeMilliMinArg, timeMilliMaxArg);
}
public async timeout(timeMilliArg: number) {
const timeout = new plugins.smartdelay.Timeout(timeMilliArg);
timeout.makeUnrefed();
await timeout.promise;
if (this._tapTest.status === 'pending') {
this._tapTest.status = 'timeout';
}
}
public async returnError(throwingFuncArg: IPromiseFunc) {
let funcErr: Error;
try {
await throwingFuncArg();
} catch (err: any) {
funcErr = err;
}
return funcErr;
}
public defer() {
return plugins.smartpromise.defer();
}
}

View File

@ -0,0 +1,13 @@
import * as plugins from './tapbundle.plugins';
export interface ITapWrapOptions {
before: () => Promise<any>;
after: () => {};
}
export class TapWrap {
public options: ITapWrapOptions;
constructor(optionsArg: ITapWrapOptions) {
this.options = optionsArg;
}
}

7
ts/tapbundle.plugins.ts Normal file
View File

@ -0,0 +1,7 @@
// 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 { smartdelay, smartenv, smartexpect, smartpromise };

View File

@ -0,0 +1,7 @@
import * as plugins from './tapbundle.plugins';
export class TapCreator {
// TODO:
}
export let tapCreator = new TapCreator();

25
ts/webhelpers.ts Normal file
View 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();

View File

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

1706
yarn.lock

File diff suppressed because it is too large Load Diff