0.0.0 • Published 10 years ago

tapestry v0.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Tapestry

A minimal JavaScript testing framework for frontends and backends.

Goals

  1. Easy to test with.
  2. Easy to extend.
  3. Handle sync/async tests.
  4. Group tests into suites.
  5. Enable nesting test suites.
  6. Skippable tests / suites. Conditionally skip tests (For example, if network is unavailable).
  7. 'Todo' tests / suites. Write tests before the tested feature is ready, and mark the test as 'todo'. The test may fail, but it won't count until the feature is actually implemented.
  8. Suites are runnable scripts.
  9. Run both in browser and node.
  10. Have an optional TAP reporter.

Demo

See demo.js for current functionalities.

Run it with different reporters:

  • node demo/demo --tree
  • node demo/demo --TAP

Output of demo script on Node:

Demo Node

Output of demo script on the browser (using browserify);

Demo Browser

Usage & API

  1. Tests are grouped into suites.
  2. Suites are defined with suite( ... ).

    suite("suite's description", function(test, suite){
        // ...
    });
  3. Suites can be nested.

    suite("suite's description", function(test, suite){
    
        suite("nested suite", function(test, suite){
            // ...
        });
    
        suite("another nested suite", function(test, suite){
            // ...
        });
    
    });
  4. Tests can be synchronous.

    suite("suite's description", function(test, suite){
    
        test("a sync test", function(){
            throw Error("This test will fail!");
        });
    
    });
  5. Tests can be asynchronous.

    suite("suite's description", function(test, suite){
    
        test("a sync test", function(t){
            setTimout(function(){
                t.notOK("This test will fail!");
            }, 100);
        });
    
    });
  6. Async tests may throw exceptions to indicate failure.

    suite("suite's description", function(test, suite){
    
        test("a sync test", function(t){
            setTimout(function(){
                throw Error("This test will fail!");
            }, 100);
        });
    
    });

    But remember to indicate the test is async by passing the t parameter.