VimUnDosNjz` 7T-[K|KuQ7777N7_/NaqIImplementation of test runner compatible with [CommonJS Unit Testing/1.1]5_1NdqKImplementation of test runner compatible with [UnCommonJS Unit Testing/1.1]5_JNkqKImplementation of test runner compatible with [UncommonJS Unit Testing/1.1]5_..>v>Ntq?Implementation of test runner compatible with [UncommonJS Unit]5_..>v>Nuq.Implementation of test runner compatible with 5_.>v>Nxq(Implementation of test runner compatible5_.>v>N|q9Implementation of [UncommonJS Unit]test runner compatible5_ #.>v>Nq9Implementation of [UncommonJS unit]test runner compatible5_ ..>v>Nq9Implementation of [UncommonJS unit test runner compatible5_ :.>v>Nq:Implementation of [UncommonJS unit test runner] compatible5_ oooIvINnpqJ[CommonJS Unit Testing/1.1]:http://wiki.commonjs.org/wiki/Unit_Testing/1.15_ ooovNnpqf[CommonJS Unit Testing/1.1]:https://github.com/kriskowal/uncommonjs/blob/master/tests/specification.md5_  mmmvNlnq.the [CommonJS Unit Testing/1.1] specification.5_  mmvNq- "dependencies": { "test": ">=0.0.5" }5_mmvNq. "ddependencies": { "test": ">=0.0.5" }5_ mmvNq. "ddependencies": { "test": ">=0.0.5" }5_mmvN-[Gist version](http://gist.github.com/616484)5_llvN5_CkkvNoD- Test your package by running all tests `npm test mypackage@active`5_ kkvNo6 or run individual tests `node path/to/test/group.js`5_vNoCommonJS Test Runner5_vN ====================5_vN nUncommonJS unit test runner5_vN n# UncommonJS unit test runner5_vN-------5_vNmTesting5_ vNm ## Testing5_vNm { "name": "mypackage", "version": "0.7.0",( "description": "Sample package",2 "scripts": { "test": "node test/all.js" },0 "devDependencies": { "test": ">=0.0.5" } }5_%dvN emGK // if test function expects second named argument it will be executedN // in async mode and test will be complete only after callback is called= exports['test my async foo'] = function(assert, done) {" var http = require('http')A var google = http.createClient(80, 'www.jeditoolkit.com')Q var request = google.request('GET', '/', {'host': 'www.jeditoolkit.com'}) request.end()4 request.on('response', function (response) {T assert.equal(response.statusCode, 302, 'must redirect') // will log result& response.setEncoding('utf8')0 response.on('data', function (chunk) {U assert.notEqual(chunk, 'helo world', 'must be something more inteligent')H done() // telling test runner that we're done with this test }) }) }> if (module == require.main) require('test').run(exports)- test/fail-slow.jsI // using assert passed to the test function that just logs failuresA exports['test that logs all failures'] = function(assert) {: assert.equal(2 + 2, 5, 'assert failure is logged')7 assert.equal(3 + 2, 5, 'assert pass is logged') }> if (module == require.main) require('test').run(exports)- test/fail-fast.js> // using nodejs's build in asserts that throw on failure$ var assert = require('assert')J exports['test that stops execution on first failure'] = function() {K assert.equal(2 + 2, 5, 'assert fails and test execution stop here')N assert.equal(3 + 2, 5, 'will never pass this since test failed above') }> if (module == require.main) require('test').run(exports) test/custom-assert.js/ var AssertBase = require('assert').Assert var AssertDescriptor = {' constructor: { value: Assert },C inRange: { value: function (lower, inner, upper, message) {/ if (lower < inner && inner < upper) { this.fail({ actual: inner,5 expected: lower + '> ' + ' < ' + upper," operator: "inRange", message: message }) } else { this.pass(message); } }, enumerable: true } } function Assert() {Q return Object.create(AssertBase.apply(null, arguments), AssertDescriptor) }0 // bundling custom asserts with test suite exports.Assert = Assert> exports['test with custom asserts'] = function(assert) {9 assert.inRange(2, 3, 5, 'passes assert and logs')7 assert.equal(3 + 2, 5, 'assert pass is logged') }> if (module == require.main) require('test').run(exports)5_&$%3 3 9 v N2:mK // using assert passed to the test function that just logs failuresC exports['test that logs all failures'] = function(assert) {< assert.equal(2 + 2, 5, 'assert failure is logged')9 assert.equal(3 + 2, 5, 'assert pass is logged') }@ if (module == require.main) require('test').run(exports)5_%'&23 9 v N24n24m5_&(':4 : v N:<o :<n5_')(??gvN>ho)@ // using nodejs's build in asserts that throw on failure& var assert = require('assert')L exports['test that stops execution on first failure'] = function() {M assert.equal(2 + 2, 5, 'assert fails and test execution stop here')P assert.equal(3 + 2, 5, 'will never pass this since test failed above') }@ if (module == require.main) require('test').run(exports) test/custom-assert.js1 var AssertBase = require('assert').Assert var AssertDescriptor = {) constructor: { value: Assert },E inRange: { value: function (lower, inner, upper, message) {1 if (lower < inner && inner < upper) { this.fail({ actual: inner,7 expected: lower + '> ' + ' < ' + upper,$ operator: "inRange", message: message }) } else {! this.pass(message); } }, enumerable: true } } function Assert() {S return Object.create(AssertBase.apply(null, arguments), AssertDescriptor) }2 // bundling custom asserts with test suite exports.Assert = Assert@ exports['test with custom asserts'] = function(assert) {; assert.inRange(2, 3, 5, 'passes assert and logs')9 assert.equal(3 + 2, 5, 'assert pass is logged') }@ if (module == require.main) require('test').run(exports)5_(*)>?gvN>@p>@o5_)+*g@hvNgiq gip5_*,+i@ivNhi5_+-,i@ivN hi5_,.- @ivNpo5_-/.  1vN2qM // if test function expects second named argument it will be executedP // in async mode and test will be complete only after callback is called? exports['test my async foo'] = function(assert, done) {$ var http = require('http')C var google = http.createClient(80, 'www.jeditoolkit.com')S var request = google.request('GET', '/', {'host': 'www.jeditoolkit.com'}) request.end()6 request.on('response', function (response) {V assert.equal(response.statusCode, 302, 'must redirect') // will log result( response.setEncoding('utf8')2 response.on('data', function (chunk) {W assert.notEqual(chunk, 'helo world', 'must be something more inteligent')J done() // telling test runner that we're done with this test }) }) }@ if (module == require.main) require('test').run(exports)5_.0/ 1vN5_/1000vN02q 02p5_021vNq { "name": "mypackage", "version": "0.7.0",* "description": "Sample package",4 "scripts": { "test": "node test/all.js" },2 "devDependencies": { "test": ">=0.0.5" } }5_132vNrq5_243vN s r5_354NvN-MOs test/custom-assert.js5_465N vN0MOs - test/custom-assert.js5_576LvN3LNt LNs5_67PvN6PRuPRt5_ %$339 v N24mG // using assert passed to the test function that just logs failures5_!$ 3=gVN 2:mM // using assert passed to the test function that just logs failuresE exports['test that logs all failures'] = function(assert) {> assert.equal(2 + 2, 5, 'assert failure is logged'); assert.equal(3 + 2, 5, 'assert pass is logged') }B if (module == require.main) require('test').run(exports)5_ #!==gVN<hm+B // using nodejs's build in asserts that throw on failure( var assert = require('assert')N exports['test that stops execution on first failure'] = function() {O assert.equal(2 + 2, 5, 'assert fails and test execution stop here')R assert.equal(3 + 2, 5, 'will never pass this since test failed above') }B if (module == require.main) require('test').run(exports)! test/custom-assert.js3 var AssertBase = require('assert').Assert" var AssertDescriptor = {+ constructor: { value: Assert },G inRange: { value: function (lower, inner, upper, message) {3 if (lower < inner && inner < upper) { this.fail({ actual: inner,9 expected: lower + '> ' + ' < ' + upper,& operator: "inRange"," message: message }) } else {# this.pass(message); }! }, enumerable: true } } function Assert() {U return Object.create(AssertBase.apply(null, arguments), AssertDescriptor) }4 // bundling custom asserts with test suite! exports.Assert = AssertB exports['test with custom asserts'] = function(assert) {= assert.inRange(2, 3, 5, 'passes assert and logs'); assert.equal(3 + 2, 5, 'assert pass is logged') }B if (module == require.main) require('test').run(exports)5_!"#g=gVNfh5_!#"g=gVNfh5_ bbvN!q[Gist versio/fail-slow.js5_  v Nf[Gist versio/fail-slow.js5