0.0.0 • Published 10 years ago
tapestry v0.0.0
A minimal JavaScript testing framework for frontends and backends.
Goals
- Easy to test with.
- Easy to extend.
- Handle sync/async tests.
- Group tests into suites.
- Enable nesting test suites.
- Skippable tests / suites. Conditionally skip tests (For example, if network is unavailable).
- '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.
- Suites are runnable scripts.
- Run both in browser and node.
- 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:
Output of demo script on the browser (using browserify);
Usage & API
- Tests are grouped into suites.
Suites are defined with
suite( ... )
.suite("suite's description", function(test, suite){ // ... });
Suites can be nested.
suite("suite's description", function(test, suite){ suite("nested suite", function(test, suite){ // ... }); suite("another nested suite", function(test, suite){ // ... }); });
Tests can be synchronous.
suite("suite's description", function(test, suite){ test("a sync test", function(){ throw Error("This test will fail!"); }); });
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); }); });
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.
0.0.0
10 years ago