Security News
OpenJS: “XZ Utils Cyberattack Likely Not an Isolated Incident”
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Weekly downloads
Readme
Returns a deep copy of an object with all functions converted to spies.
Install with npm
:
npm install 007
// we want to test github
var github = require('github');
var doubleOhSeven = require('007');
var mockGithub = doubleOhSeven(github);
mockGithub.pullRequests.getCommits.returns = function () {
return {
foo: 'beep'
};
};
assert(mockGithub.pullRequests.getCommits('lalala').foo === 'beep');
assert(mockGithub.pullRequests.getCommits.callCount === 1);
doubleOhSeven()
Takes an object or function as an argument, returns a function or object matching the original, but with mocked out functions.
mockFn.implementation
The implementation of the mock function.
Set with =
:
Ex:
mockFn.implementation = function (val, cb) {
return cb(val + 1);
};
The following functions are helpers for implementation; using them will override mockFn.implementation
.
mockFn.returns()
The return value of the mock.
Ex:
mockFn.returns('foo');
mockFn(function (arg) {
console.log(arg); // outputs 'foo'
});
mockFn.callbackArgs()
The callback args to be invoked by the mock.
Ex:
mockFn.callbackArgs(['foo']);
mockFn(function (arg) {
console.log(arg); // outputs 'foo'
});
MIT
FAQs
Returns a deep copy of an object with all functions converted to spies
The npm package 007 receives a total of 15 weekly downloads. As such, 007 popularity was classified as not popular.
We found that 007 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Company News
Come meet the Socket team at BSidesSF and RSA! We're sponsoring several fun networking events and we would love to see you there.
Security News
OSI is starting a conversation aimed at removing the excuse of the SaaS loophole for companies navigating licensing and the complexities of doing business with open source.