redtea
Test framework for JavaScript.
Usage
// test.js; ;
sudo npm install --global redteanpm install --save-dev redtearedtea test.js
My tests
Number (number 1)
√ is a Number
1 test(s), 1 passed, 0 failed
describe
describe()
is the core function of redtea
. It will assert a given value against an object of properties.
Notation
type Function;
Example
;
batch
Use batch
if you want to group tests together. You can use nested groups of tests this way too.
Notation
type Function;
Example
describe;
promise
You can evaluate the return of a promise using promise
.
Notation
type PROMISE = label: string Promise assertions: ASSERTIONS;
Example
describe; // Catching errorsdescribe;
emitter
You can also assert events emitted by an emitter.
Notation
type EMITTER = label: string EventEmitter assertions: ASSERTIONS;
Example
; { super; thisname = name; process; } { this; } describe; // Make sure some events are not emitteddescribe;
Assertions
Notations
type ASSERTIONS = type?: TYPE types?: TYPE mixed?: TYPE mixedArray?: TYPE value?: any has?: any shape?: Object some?: boolean every?: boolean above: number | Date below: number | Date not?: ASSERTIONS emits: EMITTERS; type TYPE = Function | null | TYPE_EXTRA | Array<Function | null | TYPE_EXTRA>; type TYPE_EXTRA = mixed?: TYPE; type EMITTERS = event: string: ASSERTIONS & wait?: Number;
value: any
The value to match that. We use lodash's isEqual for comparisons.
;
type: TYPE
Type comparison.
;; {}; // Arrays;
mixed: Array<TYPE>
;
mixedArray: Array<TYPE>
;
has: any
String
Will perform a regular expression
;
Array
Has at least one item matching.
;
Object
Check if properties exist.
;// property exists;// properties exist;
some: (item: any, index: number, items: Array<any>) => boolean
Check if some items of the array match.
;
every: (item: any, index: number, items: Array<any>) => boolean
Check if every items of the array match.
;
above: number | Date
; ;
below: number | Date
; ;
between: Array<number> | Array<Date>
; ;