update docs

This commit is contained in:
Philipp Kunz 2017-05-04 23:15:08 +02:00
parent 36574d0f34
commit f16e25b413
4 changed files with 63 additions and 8 deletions

View File

@ -1,5 +1,6 @@
import { TapTools } from './tapbundle.classes.taptools';
import { HrtMeasurement } from 'early';
import { Deferred } from 'smartq';
export declare type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout';
export interface ITestFunction {
(tapTools?: TapTools): Promise<any>;
@ -12,6 +13,8 @@ export declare class TapTest {
status: TTestStatus;
tapTools: TapTools;
testFunction: ITestFunction;
testDeferred: Deferred<TapTest>;
testPromise: Promise<TapTest>;
/**
* constructor
*/

View File

@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./tapbundle.plugins");
const tapbundle_classes_taptools_1 = require("./tapbundle.classes.taptools");
// imported interfaces
const early_1 = require("early");
@ -16,6 +17,8 @@ class TapTest {
* constructor
*/
constructor(optionsArg) {
this.testDeferred = plugins.smartq.defer();
this.testPromise = this.testDeferred.promise;
this.description = optionsArg.description;
this.hrtMeasurement = new early_1.HrtMeasurement();
this.parallel = optionsArg.parallel;
@ -37,14 +40,18 @@ class TapTest {
this.hrtMeasurement.stop();
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
this.status = 'success';
this.testDeferred.resolve(this);
}
catch (err) {
this.hrtMeasurement.stop();
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
this.testDeferred.reject();
// 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');
}
// if the test is allowed to fail
if (this.failureAllowed) {
console.log(`please note: failure allowed!`);
}
@ -54,4 +61,4 @@ class TapTest {
}
}
exports.TapTest = TapTest;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjoz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FjLENBQUMsQ0FBQyxDQUFDO29CQUN4QixPQUFPLENBQUMsR0FBRyxDQUFDLCtCQUErQixDQUFDLENBQUE7Z0JBQzlDLENBQUM7Z0JBQ0QsT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQTtZQUNsQixDQUFDO1FBQ0gsQ0FBQztLQUFBO0NBQ0Y7QUExREQsMEJBMERDIn0=

View File

@ -24,16 +24,51 @@ Use TypeScript for best in class instellisense.
This package includes
* tap compatible testing framework written in TypeScript
* npm package chai
* npm package chai-as-promised
* npm package @types/tap
* npm pacakge @types/chai
* npm package @types/chai-as-promised
* npm package chai (through smartchai)
* npm package chai-as-promised (through smartchai)
* npm package chai-string (through smartchai)
* npm pacakge @types/chai (through smartchi)
* npm package @types/chai-as-promised (through smartchai)
* npm package @types/chai-string (through smartchai)
In other words: This pacakge is fully typed :)
It also implements its own tap testing engine, that is fully typed.
In other words: This package is fully typed :)
### Get started with writing your first test file.
```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.eventuall.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.

View File

@ -1,8 +1,10 @@
import * as plugins from './tapbundle.plugins'
import { tapCreator } from './tapbundle.tapcreator'
import { TapTools } from './tapbundle.classes.taptools'
// imported interfaces
import { HrtMeasurement } from 'early'
import { Deferred } from 'smartq'
// interfaces
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout'
@ -20,6 +22,8 @@ export class TapTest {
status: TTestStatus
tapTools: TapTools
testFunction: ITestFunction
testDeferred: Deferred<TapTest> = plugins.smartq.defer()
testPromise: Promise<TapTest> = this.testDeferred.promise
/**
* constructor
*/
@ -49,13 +53,19 @@ export class TapTest {
this.hrtMeasurement.stop()
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`)
this.status = 'success'
this.testDeferred.resolve(this)
} catch (err) {
this.hrtMeasurement.stop()
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`)
this.testDeferred.reject()
// 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')
}
// if the test is allowed to fail
if (this.failureAllowed) {
console.log(`please note: failure allowed!`)
}