Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

qunit example

Tj Holowaychuk8574c67b1490
diff --git a/index.md b/index.md
index aacbd5d8..3529ca38 100644
--- a/index.md
+++ b/index.md
@@ -265,6 +265,34 @@ Testing asynchronous code with Mocha could not be simpler! Simply invoke the cal
}
};
+### QUnit
+
+ The qunit-inspired interface matches the "flat" look of QUnit where the test suite title is simply defined before the test-cases.
+
+ function ok(expr, msg) {
+ if (!expr) throw new Error(msg);
+ }
+
+ suite('Array');
+
+ test('#length', function(){
+ var arr = [1,2,3];
+ ok(arr.length == 3);
+ });
+
+ test('#indexOf()', function(){
+ var arr = [1,2,3];
+ ok(arr.indexOf(1) == 0);
+ ok(arr.indexOf(2) == 1);
+ ok(arr.indexOf(3) == 2);
+ });
+
+ suite('String');
+
+ test('#length', function(){
+ ok('foo'.length == 3);
+ });
+
## Reporters
Mocha reporters adjust to the terminal window,