{"id":22144973,"url":"https://github.com/jim/dollar_spec","last_synced_at":"2025-08-16T16:07:30.303Z","repository":{"id":590763,"uuid":"225144","full_name":"jim/dollar_spec","owner":"jim","description":"A small pure JavaScript spec framework","archived":false,"fork":false,"pushed_at":"2010-10-13T17:33:05.000Z","size":136,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T12:19:39.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jim.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-06-12T05:56:15.000Z","updated_at":"2013-12-20T15:10:14.000Z","dependencies_parsed_at":"2022-08-16T10:31:09.647Z","dependency_job_id":null,"html_url":"https://github.com/jim/dollar_spec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jim/dollar_spec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fdollar_spec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fdollar_spec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fdollar_spec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fdollar_spec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jim","download_url":"https://codeload.github.com/jim/dollar_spec/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fdollar_spec/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270735027,"owners_count":24636287,"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","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-01T22:36:48.995Z","updated_at":"2025-08-16T16:07:30.261Z","avatar_url":"https://github.com/jim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"DollarSpec\n==========\n\nDollar spec is a tiny JavaScript spec framework that gets out of the way and lets you get things done. It supports nested describes and before/after blocks, but that is about it. The standard set of expectations is small right now, but they are easy to add.\n\n## Why another JavaScript spec framework?\n\nI wanted a small, pure-JS framework that supported a syntax I didn't have to think too much to use. I wanted to only add as much syntax as was neccessary, and leave the rest to JavaScript. I want to run JavaScript tests from the console.\n\nAlso, I wanted minimal namespace usage. DollarSpec creates a single global entity, \u003ccode\u003e$spec\u003c/code\u003e.\n\n## Building the project\n\nYou'll probably want to build a distributable file for any kind of real use. Inside the root directory, run:\n\n    ../build\n    \nAnd you'll have a brand spanking new file at dist/dollar_spec.js for use as you se fit.\n\n## Getting Started\n\nHere's a sample spec (you can see the complete example in example/addition.html):\n\n    $spec.describe('my awesome addition function', function(spec) {\n        \n        var add = function() {\n           var total = 0;\n           for (var i = 0, l = arguments.length; i \u003c l; i++) {\n               total += arguments[i];\n           }\n           return total;\n        };\n\n        spec.it('adds two numbers', function(expect) {\n            expect(add(2,2)).to.equal(4);\n        });\n    });\n    \n    $spec.run();\n    \nIf you run this inside Firefox, you will get some messages in the Firebug console, although these can be adjusted to your liking:\n\n    // To disable console output (defaults to true)\n    $spec.opts.console = false;\n\n    // Print a line to the console for each test (defaults to false)\n    $spec.opts.verbose = true;\n\nIf you don't want to use the console reporting, the results of all specs are collected and returned by \u003ccode\u003e$spec.stats()\u003c/code\u003e. This makes it easy to do whatever you wish with the results.\n\n## Custom expectations\n\nDollarSpec's expectations are built from two pieces- verbs and matchers.\n\n### Verbs\n\nA verb is a function that can be used in an expectation to define something about the parameters of what is expected. The most basic verbs simply define which matcher to use. Verbs must always return \u003ccode\u003ethis\u003c/code\u003e in order to allow chaining to work. Here is the verb definition for \u003ccode\u003eequal\u003c/code\u003e:\n\n    $spec.verb('equal', function(expected) {\n      this.set('matcher', 'equal');\n      this.set('expected', expected);\n      return this;\n    });\n\nThis verb will cause the expectation to use the \u003ccode\u003eequal\u003c/code\u003e matcher, and stores the value of \u003ccode\u003eexpected\u003c/code\u003e so it can be examined in the matcher later.\n\n### Matchers\n\nMatchers are functions that determine if an expectation passes or fails. They can also define messages to be displayed to the user when a test fails. Here's the \u003ccode\u003ebeA\u003c/code\u003e matcher:\n\n    $spec.matcher('beA', function(result) {\n      result.failure = \"Expected an instance of \" + this.klass.toString() + \", but it was \" + typeof(this.actual);\n      result.negatedFailure = \"Expected instance of a class other than \" + this.klass.toString() + \", but it was one\";\n  \n      return this.actual instanceof(this.klass);\n    });\n\n\u003ccode\u003eresult.negatedFailure\u003c/code\u003e is the message to be displayed when the tests passes, but was used in a negated expectation using \u003ccode\u003enot()\u003c/code\u003e.\n\n## Running the test suite\n\nThe project's specs use [diligence](http://github.com/jim/diligence), a small JavaScript remote test runner. A copy is included with the project, but you will need a working installation of [Node](http://tinyclouds.org/node/). To run the tests, run these commands from inside the project directory:\n\n    cd spec\n    node suite.js\n    \nAnd then point your browser to localhost:5678. You should see '23 passed' in the browser, and something similar in the the console.\n\n## Built in verbs and matchers\n\nKeep in mind that any expectation can be negated using \u003ccode\u003enot()\u003c/code\u003e. For example:\n\n    expect(3).to.not().equal(8);\n\n### expect(actual).to.equal(expected)\n\nCompares \u003ccode\u003eactual\u003c/code\u003e and \u003ccode\u003eexpected\u003c/code\u003e using \u003ccode\u003e===\u003c/code\u003e.\n\n### expect(actual).to.beA(Object)\n\nVerifies that \u003ccode\u003eactual\u003c/code\u003e is an instance of \u003ccode\u003eObject\u003c/code\u003e.\n\n### expect(actual).to.beUndefined()\n\nVerifies that \u003ccode\u003eactual\u003c/code\u003e is undefined.\n\n### expect(actual).to.beNull()\n\nVerifies that \u003ccode\u003eactual\u003c/code\u003e is null.\n\n### expect(affectorFunction).to.change(affectedFunction)\n\nCompares the value returned from calling \u003ccode\u003eaffectedFunction\u003c/code\u003e before and after calling \u003ccode\u003eaffectorFunction\u003c/code\u003e.\n\n### expect(affectorFunction).to.change(affectedFunction).by(amount)\n\nCompares the difference between the value returned from calling \u003ccode\u003eaffectedFunction\u003c/code\u003e before and after calling \u003ccode\u003eaffectorFunction\u003c/code\u003e to \u003ccode\u003eamount\u003c/code\u003e.\n\n### expect(callbackFunction).to.raiseError([verifyFunction])\n\nVerifies that \u003ccode\u003ecallbackFunction\u003c/code\u003e raises an exception when called.\n\nOptionally will call \u003ccode\u003everifyFunction\u003c/code\u003e and pass in a raised exception for further inspection. \u003ccode\u003everifyFunction\u003c/code\u003e must return \u003ccode\u003etrue\u003c/code\u003e or \u003ccode\u003efalse\u003c/code\u003e.\n\n## Inspiration\n\nI've looked at most of the various JavaScript TDD/BDD libraries in the past few weeks. I'm trying to achieve the readability of RSpec, but with the smallest possible syntax, and hopefully without the use of \u003ccode\u003ewith\u003c/code\u003e.\n\n## Alternatives\n\nYou should probably take a look at [ScrewUnit](http://github.com/nathansobo/screw-unit/tree/master) if you're looking for a more complete/mature BDD framework.\n\n## Feedback\n\nThoughts and feedback are welcomed and encouraged.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim%2Fdollar_spec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjim%2Fdollar_spec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim%2Fdollar_spec/lists"}