Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
8bf99ae7ec | |||
cc708b29ae | |||
5798d3e808 | |||
37fe299a45 |
2978
package-lock.json
generated
2978
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/tapbundle",
|
"name": "@pushrocks/tapbundle",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "4.0.3",
|
"version": "4.0.5",
|
||||||
"description": "tap bundled for tapbuffer",
|
"description": "tap bundled for tapbuffer",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@ -20,18 +20,18 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
"homepage": "https://gitlab.com/pushrocks/tapbundle#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@open-wc/testing-helpers": "^2.0.3",
|
"@open-wc/testing-helpers": "^2.0.4",
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartenv": "^4.0.16",
|
"@pushrocks/smartenv": "^4.0.16",
|
||||||
"@pushrocks/smartexpect": "^1.0.11",
|
"@pushrocks/smartexpect": "^1.0.12",
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
"@pushrocks/smarttime": "^3.0.43"
|
"@pushrocks/smarttime": "^3.0.45"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.29",
|
"@gitzone/tsbuild": "^2.1.29",
|
||||||
"@gitzone/tsrun": "^1.2.18",
|
"@gitzone/tsrun": "^1.2.18",
|
||||||
"@gitzone/tstest": "^1.0.60",
|
"@gitzone/tstest": "^1.0.64",
|
||||||
"@types/node": "^17.0.14",
|
"@types/node": "^17.0.18",
|
||||||
"randomstring": "^1.2.2",
|
"randomstring": "^1.2.2",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
29
readme.md
29
readme.md
@ -1,5 +1,5 @@
|
|||||||
# @pushrocks/tapbundle
|
# @pushrocks/tapbundle
|
||||||
tap bundled for tapbuffer
|
tap based testing framework for use with @gitzone/tstest
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/tapbundle)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/tapbundle)
|
||||||
@ -31,14 +31,17 @@ A few words on TypeScript
|
|||||||
|
|
||||||
### Included in this package
|
### Included in this package
|
||||||
|
|
||||||
- tap compatible testing framework written in TypeScript
|
* tap compatible testing framework written in TypeScript
|
||||||
- a collection of test tools
|
* `expect` and `expectAsync` from the package `@pushrocks/smartexpect`
|
||||||
- **code** testing framework with typings
|
|
||||||
|
### A few words on tap
|
||||||
|
|
||||||
|
tap stands for **test anything protocol**. Its programming language agnostic as long as the test interpreter can read the tap console output. This package is optimized to work with @gitzone/tstest as interpreter, which offers different V8 based runtime environments like nodejs, chrome, and deno.
|
||||||
|
|
||||||
### Write your first tests
|
### Write your first tests
|
||||||
|
|
||||||
```javascript
|
```typescript
|
||||||
import { tap, expect } from 'tapbundle'; // has typings in place
|
import { tap, expect, expectAsync } from 'tapbundle'; // has typings in place
|
||||||
|
|
||||||
import * as myAwesomeModuleToTest from '../dist/index'; // '../dist/index' is the standard path for npmts modules
|
import * as myAwesomeModuleToTest from '../dist/index'; // '../dist/index' is the standard path for npmts modules
|
||||||
|
|
||||||
@ -47,25 +50,27 @@ tap.test('my awesome description', async (tools) => {
|
|||||||
tools.timeout(2000); // test will fail if it takes longer than 2000 millisenconds
|
tools.timeout(2000); // test will fail if it takes longer than 2000 millisenconds
|
||||||
});
|
});
|
||||||
|
|
||||||
let myTest2 = tap.test('my awesome test 2', async (tools) => {
|
const myTest2 = tap.test('my awesome test 2', async (tools) => {
|
||||||
myAwsomeModuleToTest.doSomethingAsync(); // we don't wait here
|
myAwsomeModuleToTest.doSomethingAsync(); // we don't wait here
|
||||||
await tools.delayFor(3000); // yay! :) promise based timeouts :)
|
await tools.delayFor(3000); // yay! :) promise based timeouts :)
|
||||||
console.log('This gets logged 3000 ms into the test');
|
console.log('This gets logged 3000 ms into the test');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('my awesome test 3', async (tools) => {
|
tap.test('my awesome test 3', async (tools) => {
|
||||||
expect(true).to.be.true; // will not throw
|
expect(true).toBeTrue(); // will not throw
|
||||||
await expect(tools.delayFor(2000)).to.eventually.be.fulfilled; // yay expect promises :)
|
await expectAsync(tools.delayFor(2000)).toBeUndefined(); // yay expect promises :)
|
||||||
expect((await myTest2.promise).hrtMeasurement.milliSeconds > 1000).to.be.true; // access other tests metadata :)
|
expectAsync(myTest2.promise) // access other tests metadata :)
|
||||||
|
.property('hrtMeasurement') // and drill down into properties
|
||||||
|
.property('milliSeconds').toBeGreaterThan(1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
let myTest4 = tap.testParallel('my awesome test 4', async (tools) => {
|
const myTest4 = tap.testParallel('my awesome test 4', async (tools) => {
|
||||||
await tools.delayFor(4000);
|
await tools.delayFor(4000);
|
||||||
console.log('logs to console after 4 seconds into this test');
|
console.log('logs to console after 4 seconds into this test');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('my awesome test 5', async () => {
|
tap.test('my awesome test 5', async () => {
|
||||||
expect(myTest4.status).to.equal('pending'); // since this test will likely finish before myTest4.
|
expect(myTest4.status).toEqual('pending'); // since this test will likely finish before myTest4.
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start(); // start the test, will automtically plan tests for you (so the tap parser knows when tests exit bofore they are finished)
|
tap.start(); // start the test, will automtically plan tests for you (so the tap parser knows when tests exit bofore they are finished)
|
||||||
|
Reference in New Issue
Block a user