Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

testdouble

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testdouble - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.travis.yml

2

main.js
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc