b0VIM 7.3ܮLSfgozalajarti.lan~gozala/Projects/test-commonjs/README.mdutf-8 3210#"! Utpl fadlzy;:3  d c T S 7  m B  [  f P  n  onZYZRQLihJIaJ-uiKC) c$ assert.inRange(2, 3, 5, 'passes assert and logs') exports['test with custom asserts'] = function(assert) { exports.Assert = Assert // bundling custom asserts with test suite } ) , AssertDescriptor ( AssertBase.apply(null, arguments) return Object.create function Assert() { } }, enumerable: true } } this.pass(message); } else { }) , message: message , operator: "inRange" , expected: lower + '> ' + ' < ' + upper { actual: inner, this.fail( if (lower < inner && inner < upper) { , inRange: { value: function (lower, inner, upper, message) { { constructor: { value: Assert } var AssertDescriptor = var AssertBase = require('assert').Assert test/custom-assert.js if (module == require.main) require('test').run(exports) } assert.equal(3 + 2, 5, 'will never pass this since test failed above') assert.equal(2 + 2, 5, 'assert fails and test execution stop here') exports['test that stops execution on first failure'] = function() { var assert = require('assert') // using nodejs's build in asserts that throw on failure- test/fail-fast.js if (module == require.main) require('test').run(exports) } assert.equal(3 + 2, 5, 'assert pass is logged') assert.equal(2 + 2, 5, 'assert failure is logged') exports['test that logs all failures'] = function(assert) { // using assert passed to the test function that just logs failures- test/fail-slow.js if (module == require.main) require('test').run(exports) } }) }) done() // telling test runner that we're done with this test assert.notEqual(chunk, 'helo world', 'must be something more inteligent') response.on('data', function (chunk) { response.setEncoding('utf8') assert.equal(response.statusCode, 302, 'must redirect') // will log result request.on('response', function (response) { request.end() var request = google.request('GET', '/', {'host': 'www.jeditoolkit.com'}) var google = http.createClient(80, 'www.jeditoolkit.com') var http = require('http') exports['test my async foo'] = function(assert, done) { // in async mode and test will be complete only after callback is called // if test function expects second named argument it will be executed- test/fail-slow.js } , "dependencies": { "test": ">=0.0.5" } , "engines": { "node": ">=0.1.103" } , "scripts": { "test": "node test/all.js" } } , "test": "./test" { "lib": "./lib" , "directories": , "description": "Sample package" , "version": "0.7.0" { "name": "mypackage"- package.json[Gist version](http://gist.github.com/616484)####Example#### or run individual tests `node path/to/test/group.js`- Test your package by running all tests `npm test mypackage@active`- Write your tests- Define dependency on this package (It's name is "test" in [npm] registry).- Define test script in package descriptor under `scripts` section.- Define test directory in package descriptor under `directories` section.- Create a directory in your package root.In order to make your package testable from [npm] you should:-------TestingImplementation of test runner compatible with [CommonJS Unit Testing/1.1]====================CommonJS Test RunneradN ~}2[npm]:http://npmjs.org/[CommonJS Unit Testing/1.1]:http://wiki.commonjs.org/wiki/Unit_Testing/1.1the [CommonJS Unit Testing/1.1] specification.For more examples checkout tests for this package and for more details see if (module == require.main) require('test').run(exports) } assert.equal(3 + 2, 5, 'assert pass is logged')