Skip to content

Async tests and particular output

Compare
Choose a tag to compare
@titulus titulus released this 15 Aug 17:58
· 89 commits to master since this release

Changelog

  • changes in code
    • serious refactor, changed technique of nesting and chaining
    • provide executing in non-window enviroment (like node.js)
    • made .done() chain-closer to provide output a particular group or test
  • additions
    • chain-link .addTrace(level)
    • chain-prep .time to calculate time spended on test
    • chain-prep .exclude which made test/group unpushable into stack of current level group
  • fixes
    • fix time recalculation in test.done()
    • fix many grammar errors #1
  • wiki updated

Particular outout

Output a particular group or test availible from now

example:

test.done(); // outputs the root

test.group('first group',function(){
    ...
    test.done(); // outputs the first group
});

test.group('first group').done(); // outputs the first group

test.it(someThing).done(); // outputs the test

Async tests

Async tests availible from now
To test the async functional use the following structures

asyncFunction(); // that function will fill asyncVariable and asyncResult

// testing group of tests
setTimeout(function () {
    test.group('async tests',function(){
        test.it(asyncResult);
        test.it(asyncVariable);
    }).done(); // .done() is required to output result
}, 2000); // test group will be launched in 2 seconds

// testing single tests
setTimeout(function () {
     test.it(asyncVariable).done(); // .done() is required to output result
}, 2000); // test will be launched in 2 seconds

Tests and groups in setTimeout function will be run in root scope. For running in some group scope use group nesting.

setTimeout(function () {
    test.group('group name')
        .group('async tests',function(){
            test.it(asyncResult);
            test.it(asyncVariable);
        }).done();
}, 2000);

To prevent pushing results in stack of root use .exclude

// testing group of tests
setTimeout(function () {
    test.exclude.group('async tests',function(){
        test.it(asyncResult);
        test.it(asyncVariable);
    }).done(); // test group will not be pushed into root stack
}, 2000);

// testing single tests
setTimeout(function () {
     test.exclude.it(asyncVariable).done(); // test will not be pushed into root stack
}, 2000);