{"id":21326233,"url":"https://github.com/masylum/testosterone","last_synced_at":"2025-07-12T06:33:03.291Z","repository":{"id":1264016,"uuid":"1202971","full_name":"masylum/testosterone","owner":"masylum","description":"Virile testing for http servers or any nodejs application.","archived":false,"fork":false,"pushed_at":"2012-01-29T13:42:33.000Z","size":689,"stargazers_count":81,"open_issues_count":5,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T15:42:39.123Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://masylum.github.com/testosterone","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/masylum.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-12-28T13:34:50.000Z","updated_at":"2024-09-14T09:26:26.000Z","dependencies_parsed_at":"2022-08-16T12:50:19.554Z","dependency_job_id":null,"html_url":"https://github.com/masylum/testosterone","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/masylum/testosterone","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masylum%2Ftestosterone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masylum%2Ftestosterone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masylum%2Ftestosterone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masylum%2Ftestosterone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masylum","download_url":"https://codeload.github.com/masylum/testosterone/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masylum%2Ftestosterone/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264951610,"owners_count":23687974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T21:08:52.441Z","updated_at":"2025-07-12T06:33:03.050Z","avatar_url":"https://github.com/masylum.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ✿ Testosterone\n\nVirile testing for http servers or any nodejs application.\n\n## Installation\n\n`npm install testosterone`\n\n## WhateverDrivenDevelopment\n\nTestosterone allows you to follow BDD or TDD on any of your projects using\nthe same testing library.\n\n\u003cimg src = \"https://github.com/masylum/testosterone/raw/master/testosterone.png\" border = \"0\" /\u003e\n\n## Options\n\n  * `host`: Host to do the http calls. *localhost*\n  * `port`: Port to do the http calls. *80*\n  * `output`: Configure the amount of verbosity you want for your tests\n    * `specs`: Print the specs *true*\n    * `ticks`: Print the ✓ and ✗ ticks *true*\n    * `summary`: Prints the summary *true*\n    * `title`: Prints the title *true*\n  * `title`: Test title, it will be printed out. *Testosterone*\n  * `sync`: If set to `true`, you don't need to call `done` to specify when your tests are done. *false*\n\n## API\n\n_testosterone_ API is simple and flexible.\n\n- `get|post|head|put|delete...(url, req, response, cb)`: Does a http call with the given request. If a response is given, testosterone will assert that the real response matches.\n- `add(spec, function(done))`: Adds a test. The test is considered executed when `done` function is called.\n- `before(function)`: Runs before each test.\n- `after(function)`: Runs after each test.\n- `run([cb])`: Runs the tests in serial. `cb` will be called once all the tests are executed.\n- `assert`: You **must** use this assert object instead of the native one.\n\nAll the functions are chainable.\n\n## Show me the code\n\nYou have more examples on the `test` folder:\n\n### HTTP testing example:\n\n``` javascript\nvar testosterone = require('testosterone')({port: 3000})\n  , assert = testosterone.assert;\n\ntestosterone\n  .get('/', function (res) {\n    assert.equal(res.statusCode, 200)\n  })\n\n  .get('/hi', function (res) {\n    assert.equal(res.statusCode, 500);\n    assert.equal(res.body, 'use post instead');\n  })\n\n  .post('/hi', {data: {message: 'hola'}}, {\n    status: 200\n  , body: 'hola'\n  });\n\n// Output\n\n$ node test.js\n\n✿ Testosterone : ✓ ✓ ✓ ✓ ✓\n» 3 responses, 5 asserts\n```\n\n### Asynchronous example:\n\n``` javascript\nvar testosterone = require('testosterone')({post: 3000, title: 'Testing async'})\n  , assert = testosterone.assert;\n\ntestosterone\n\n  .before(function () {\n    console.log('test about to run!');\n  })\n\n  // using done to tell testosterone when the test is done\n  .add('First test', function (done) {\n    setTimeout(function () {\n      assert.ok(true);\n      done();\n    }, 999);\n  })\n\n  // same but currying\n  .add('Second test', function (spec) {\n    assert.ok(true);\n\n    setTimeout(done(function () {\n      assert.ok(true);\n    }), 10);\n  })\n\n  .run(function () {\n    require('sys').print('All tests passed!');\n  });\n\n// Output\n\n$ node test.js\n\n✿ Testing async :\n\nFirst test =\u003e ✓\nSecond test =\u003e ✓ ✓\n\n» 0 responses, 3 asserts\n```\n\n### Example with [gently](https://github.com/felixge/node-gently.git) stubbing and `sync: true`:\n\n``` javascript\nvar testosterone = require('testosterone')({post: 3000, title: 'Testing with stubs', sync: true})\n  , gently = new (require('gently'))\n  , fs = require('fs')\n  , assert = testosterone.assert;\n\ntestosterone\n  .add('GIVEN foo.txt \\nWHEN its empty \\nTHEN it return null', function (spec) {\n    gently.expect(fs, 'readFile', function (path, encoding, cb) {\n      assert.equal(path, 'foo.txt');\n      cb(null, null);\n    });\n\n    fs.readFile('foo.txt', 'utf-8', function (er, data) {\n      assert.equal(er, null);\n      assert.equal(data, null);\n    });\n  })\n\n  .add('GIVEN foo.txt \\nWHEN it have content \\nTHEN it return that content', function (spec) {\n    gently.expect(fs, 'readFile', function (path, encoding, cb) {\n      assert.equal(path, 'foo.txt');\n      cb(null, 'foo');\n    });\n\n    fs.readFile('foo.txt', 'utf-8', function (er, data) {\n      assert.equal(er, null);\n      assert.equal(data, 'foo');\n    });\n  })\n\n  .run(function () {\n    require('sys').print('done!');\n  });\n\n// Output\n\n$ node test.js\n\n✿ Testing with stubs :\n\nGIVEN foo.txt\nWHEN its empty\nTHEN it return null =\u003e ✓ ✓ ✓\n\nGIVEN foo.txt\nWHEN it have content\nTHEN it return that content =\u003e ✓ ✓ ✓\n\n» 6 asserts\n```\n\n## Test\n\nIn order to run the tests type:\n\n``` bash\nnpm install\nmake test_app\nmake\n```\n\n## Credits\n\nThe *_call* function of this library is a shameless copy from [expresso](https://github.com/visionmedia/expresso) response assert done by TJ Holowaychuk ([visionmedia](http://github.com/visionmedia))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasylum%2Ftestosterone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasylum%2Ftestosterone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasylum%2Ftestosterone/lists"}