☕️ Classic, reliable, trusted test framework for Node.js and the browser
build
Tj Holowaychuk3e4b9fb4e0a0
diff --git a/index.html b/index.htmlindex 538da498..a4086909 100644--- a/index.html+++ b/index.html@@ -158,34 +158,37 @@<h2>mocha(1)</h2>-<pre><code>Usage: mocha [options] [files]--Options:-- -h, --help output usage information- -V, --version output the version number- -r, --require <name> require the given module- -R, --reporter <name> specify the reporter to use- -u, --ui <name> specify user-interface (bdd|tdd|exports)- -g, --grep <pattern> only run tests matching <pattern>- -t, --timeout <ms> set test-case timeout in milliseconds [2000]- -s, --slow <ms> "slow" test threshold in milliseconds [75]- -w, --watch watch files for changes- -C, --no-colors force disabling of colors- -c, --colors force enabling of colors- -G, --growl enable growl notification support- -S, --say [voice] enable say notification support- -d, --debug enable node's debugger- -b, --bail bail after first test failure- --globals <names> allow the given comma-delimited global [names]- --ignore-leaks ignore global variable leaks- --interfaces display available interfaces- --reporters display available reporters+<p> Usage: mocha [options] [files]</p>++<p> Options:</p>++<pre><code>-h, --help output usage information+-V, --version output the version number+-r, --require <name> require the given module+-R, --reporter <name> specify the reporter to use+-u, --ui <name> specify user-interface (bdd|tdd|exports)+-g, --grep <pattern> only run tests matching <pattern>+-t, --timeout <ms> set test-case timeout in milliseconds [2000]+-s, --slow <ms> "slow" test threshold in milliseconds [75]+-w, --watch watch files for changes+-C, --no-colors force disabling of colors+-c, --colors force enabling of colors+-G, --growl enable growl notification support+-d, --debug enable node's debugger+-b, --bail bail after first test failure+--globals <names> allow the given comma-delimited global [names]+--ignore-leaks ignore global variable leaks+--interfaces display available interfaces+--reporters display available reporters</code></pre><h3>-w, —watch</h3>-<p> Executes tests on changes to the test files.</p>+<p> Executes tests on changes to JavaScript in the CWD.</p>++<h3>-b, —bail</h3>++<p> Only interested in the first exception? use <code>--bail</code> !</p><h3>-d, —debug</h3>@@ -296,6 +299,35 @@ describe('app', function(){};</code></pre>+<h3>QUnit</h3>++<p> The qunit-inspired interface matches the “flat” look of QUnit where the test suite title is simply defined before the test-cases.</p>++<pre><code>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);+});+</code></pre>+<h2>Reporters</h2><p> Mocha reporters adjust to the terminal window,@@ -425,20 +457,30 @@ describe('app', function(){<p> Mocha runs in the browser. Every release of Mocha will have new builds of <em>./mocha.js</em> and <em>./mocha.css</em> for use in the browser. To setup Mocha for browser use all you have to do is include the script, stylesheet, tell Mocha which interface you wish to use, and then run the tests. A typical setup might look something like the following, where we call <code>mocha.setup('bdd')</code> to use the <strong>BDD</strong> interface before loading the test scripts, running them <code>onload</code> with <code>mocha.run()</code>.</p>-<pre><code><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>-<link rel="stylesheet" href="mocha.css" />-<script src="mocha.js"></script>-<script>mocha.setup('bdd')</script>-<script src="test.array.js"></script>-<script src="test.object.js"></script>-<script src="test.xhr.js"></script>-<script>- onload = function(){- mocha- .run()- .globals(['foo', 'bar']) // acceptable globals- };-</script>+<pre><code><html>+<head>+ <meta charset="utf-8">+ <title>Mocha Tests</title>+ <link rel="stylesheet" href="https://raw.github.com/visionmedia/mocha/master/mocha.css" />+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>+ <script src="https://raw.github.com/LearnBoost/expect.js/d2440da086bf8dc38c6085641f23b968a0f48b29/expect.js"></script>+ <script src="https://raw.github.com/visionmedia/mocha/master/mocha.js"></script>+ <script>mocha.setup('bdd')</script>+ <script src="test.array.js"></script>+ <script src="test.object.js"></script>+ <script src="test.xhr.js"></script>+ <script>+ $(function () {+ mocha+ .run()+ .globals(['foo', 'bar']) // acceptable globals+ })+ </script>+</head>+<body>+ <div id="mocha"></div>+</body>+</html></code></pre><p> Feel free to hot-link the <a href="https://raw.github.com/visionmedia/mocha/master/mocha.css">mocha.css</a> and <a href="https://raw.github.com/visionmedia/mocha/master/mocha.js">mocha.js</a> from GitHub.</p>@@ -541,4 +583,4 @@ describe('app', function(){<span>© 2011 TJ Holowaychuk. All rights reserved.</span></footer></body>-</html>+</html>\ No newline at end of filediff --git a/index.md b/index.mdindex a0aea15f..9db8c4ea 100644--- a/index.md+++ b/index.md@@ -269,29 +269,29 @@ Testing asynchronous code with Mocha could not be simpler! Simply invoke the calThe 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);- }+ function ok(expr, msg) {+ if (!expr) throw new Error(msg);+ }- suite('Array');+ suite('Array');- test('#length', function(){- var arr = [1,2,3];- ok(arr.length == 3);- });+ 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);- });+ 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');+ suite('String');- test('#length', function(){- ok('foo'.length == 3);- });+ test('#length', function(){+ ok('foo'.length == 3);+ });## Reporters