testdouble
Advanced tools
Comparing version 0.0.2 to 0.0.3
require('coffee-script/register') | ||
module.exports = require('./lib/testdouble.js'); | ||
module.exports = require('./lib/testdouble'); |
{ | ||
"name": "testdouble", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A minimal test double library for TDD with JavaScript", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/testdouble/testdouble.js", |
@@ -5,2 +5,40 @@ # testdouble.js | ||
This is all one big work in progress right now! | ||
The goal of this project is to provide a test-framework-agnostic test double library for JavaScript which mirrors [Mockito](http://mockito.org) pretty closely. That means each Test Double created by the library will be a spy that is also capable of stubbing values. Other conveniences (like matchers, ordered invocation & verification, etc.) will be added, but only to the extent they benefit an isolated TDD workflow. | ||
If you need a robust test double library that's designed to cover every possible use case, we recommend checking out [Sinon.JS](http://sinonjs.org). | ||
## Stubbing | ||
To stub with testdouble.js, first require it: | ||
``` | ||
var td = require('testdouble'); | ||
``` | ||
Create a test double with the `create` function: | ||
``` | ||
myTestDouble = td.create(); | ||
``` | ||
You can stub a no-arg invocation like so: | ||
``` | ||
td.when(myTestDouble()).thenReturn("HEY"); | ||
myTestDouble(); // returns "HEY" | ||
``` | ||
You can stub a specific set of args (performs lodash's `_.isEqual` on each) with: | ||
``` | ||
td.when(myTestDouble('a', 5, {foo: 'bar'})).thenReturn("YES"); | ||
myTestDouble('a', 5, {foo: 'bar'}); // returns "YES" | ||
myTestDouble('a', 5, {foo: 'baz'}); // returns undefined | ||
``` | ||
# TODO: Verifying, Matchers, Etc | ||
The rest of the stuff we'd like to do with this is a work-in-progress. See the [issues](https://github.com/testdouble/testdouble.js/issues) for more detail on where we're headed. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9117
18
44